Skip to content

Commit

Permalink
fix syntax examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy committed Sep 19, 2024
1 parent 362507e commit d734fb5
Show file tree
Hide file tree
Showing 46 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions src/content/doc-surrealdb/introduction/concepts/database.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A database within SurrealDB is contained within a [namespace](/docs/surrealdb/in

Databases are defined using the [`DEFINE DATABASE`](/docs/surrealql/statements/define/database) statement in SurrealQL. The statement requires a unique name for the database and can optionally include a comment for additional context. The following is the syntax for defining a database:

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE DATABASE [ OVERWRITE | IF NOT EXISTS ] @name [ COMMENT @string ]
```

Expand All @@ -38,4 +38,4 @@ You can also view the list of databases in your SurrealDB instance using the [`I

## Learn more

To learn more about databases and how to use them in SurrealDB, refer to the [`DEFINE DATABASE`](/docs/surrealql/statements/define/database).
To learn more about databases and how to use them in SurrealDB, refer to the [`DEFINE DATABASE`](/docs/surrealql/statements/define/database).
6 changes: 3 additions & 3 deletions src/content/doc-surrealdb/introduction/concepts/namespace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ There is no limit to the number of namespaces on SurrealDB and each namespace ca

Namespaces are defined using the [`DEFINE NAMESPACE`](/docs/surrealql/statements/define/namespace) statement in SurrealQL. The statement requires a unique name for the namespace and can optionally include a comment for additional context. The following is the syntax for defining a namespace:

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE NAMESPACE [ OVERWRITE | IF NOT EXISTS ] @name [ COMMENT @string ]
```

You can also view the list of namespaces in your SurrealDB instance using the [`INFO`](/docs/surrealql/statements/info) statement. This statement provides information about the accesses, databases, and users present in the current SurrealDB instance.

Using the [`NAMESPACE`](/docs/surrealql/statements/info) or [`NS`](/docs/surrealql/statements/info) keyword.

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
INFO FOR [ NS | NAMESPACE ];
```

Expand All @@ -43,7 +43,7 @@ By running the command above, you will get info ONLY about the current namespace
Once a namespace has been defined, the command below you will get a list of all the namespaces in your SurrealDB instance. We are still using the [`INFO`](/docs/surrealql/statements/info) statement, but we are asking for the info for [`ROOT`](/docs/surrealql/statements/info). The output will include the namespace name and a list of namespace users.


```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
INFO FOR ROOT;
```

Expand Down
28 changes: 14 additions & 14 deletions src/content/doc-surrealdb/introduction/sql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more in-depth explanations of SurrealDB concepts, see the [concepts page](/d
<th colspan="2" scope="col">Relational databases</th>
<th colspan="2" scope="col">SurrealDB</th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="Relational databases">
Expand Down Expand Up @@ -108,7 +108,7 @@ For more SurrealQL examples, see the [create](/docs/surrealql/statements/create)
<th colspan="2" scope="col">SQL</th>
<th colspan="2" scope="col">SurrealQL</th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="SQL">
Expand Down Expand Up @@ -148,7 +148,7 @@ For more SurrealQL examples, see the [select](/docs/surrealql/statements/select)
<th colspan="2" scope="col">SQL</th>
<th colspan="2" scope="col">SurrealQL</th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="SQL">
Expand All @@ -171,47 +171,47 @@ For more SurrealQL examples, see the [select](/docs/surrealql/statements/select)
SELECT name FROM person WHERE name = "Jane"
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT name FROM person WHERE name = "Jane"
SELECT name FROM person WHERE name = "Jane"
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="SQL">
EXPLAIN SELECT name FROM person WHERE name = "Jane"
EXPLAIN SELECT name FROM person WHERE name = "Jane"
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT name FROM person WHERE name = "Jane" EXPLAIN
SELECT name FROM person WHERE name = "Jane" EXPLAIN
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="SQL">
SELECT count(*) AS person_count FROM person
SELECT count(*) AS person_count FROM person
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT count() AS person_count FROM person GROUP ALL
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="SQL">
SELECT DISTINCT name FROM person
SELECT DISTINCT name FROM person
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT array::distinct(name) FROM person GROUP ALL
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="SQL">
SELECT * FROM person LIMIT 10
SELECT * FROM person LIMIT 10
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT * FROM person LIMIT 10
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="SQL">
SELECT review.*, person.name as reviewer FROM review INNER JOIN review.person_id = person.id
SELECT review.*, person.name as reviewer FROM review INNER JOIN review.person_id = person.id
</td>
<td colspan="2" scope="row" data-label="SurrealQL">
SELECT *, person.name as reviewer FROM review
SELECT *, person.name as reviewer FROM review
</td>
</tr>
</tbody>
Expand All @@ -228,7 +228,7 @@ For more SurrealQL examples, see the [update](/docs/surrealql/statements/update)
<th colspan="2" scope="col">SQL</th>
<th colspan="2" scope="col">SurrealQL</th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="SQL">
Expand Down Expand Up @@ -268,7 +268,7 @@ For more SurrealQL examples, see the [delete](/docs/surrealql/statements/delete)
<th colspan="2" scope="col">SQL</th>
<th colspan="2" scope="col">SurrealQL</th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="SQL">
Expand All @@ -295,4 +295,4 @@ For more SurrealQL examples, see the [delete](/docs/surrealql/statements/delete)
</td>
</tr>
</tbody>
</table>
</table>
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/datamodel/closures.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Since from '@components/Since.astro'

<Since v="v2.0.0" />

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
$@parameter = |@parameters| @expression;
```

Expand Down
6 changes: 3 additions & 3 deletions src/content/doc-surrealql/operators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ Below are the details for each method, including how to format your query with e

Best for smaller datasets or when the highest accuracy is required.

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
<|K,DISTANCE_METRIC|>
```

Expand All @@ -852,7 +852,7 @@ SELECT id FROM pts WHERE point <|2,EUCLIDEAN|> [2,3,4,5];

Ideal for larger datasets where performance is crucial, and a consistent distance metric can be predefined.

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
<|K|>
```

Expand All @@ -870,7 +870,7 @@ SELECT id FROM pts WHERE point <|2|> [2,3,4,5];

Recommended for very large datasets where speed is essential and some loss of accuracy is acceptable.

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
<|K,EF|>
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/alter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `ALTER` statement can be used to change definitions for defined resources.
> [!NOTE]
> Currently, the `ALTER` statement only supports modifying tables and their properties - `ALTER TABLE`, but will be expanded to include other resources.
```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
ALTER [
| TABLE [ IF NOT EXISTS ] @name
[ DROP ]
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/begin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Each statement within SurrealDB is run within its own transaction by default. Th

### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
BEGIN [ TRANSACTION ];
```

Expand Down
8 changes: 4 additions & 4 deletions src/content/doc-surrealql/statements/break.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The BREAK statement can be used to break out of a loop, such as inside one creat

### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
BREAK
```

Expand All @@ -27,12 +27,12 @@ LET $numbers = [1,2,3,4,5,6,7,8,9];
FOR $num IN $numbers {
IF $num > 5 {
BREAK;
} ELSE IF $num < 5 {
CREATE type::thing(
'person', $num
) CONTENT {
name: "Person number " + <string>$num
name: "Person number " + <string>$num
};
};
};
Expand Down Expand Up @@ -77,4 +77,4 @@ FOR $data IN array::sort::desc($weather) {
CREATE weather CONTENT $data;
};
};
```
```
4 changes: 2 additions & 2 deletions src/content/doc-surrealql/statements/cancel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Each statement within SurrealDB is run within its own transaction. If a set of c

### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
CANCEL [ TRANSACTION ];
```

Expand Down Expand Up @@ -52,4 +52,4 @@ IF account:two.balance < 0 {
};
COMMIT TRANSACTION;
```
```
4 changes: 2 additions & 2 deletions src/content/doc-surrealql/statements/commit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Each statement within SurrealDB is run within its own transaction by default. If

### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
COMMIT [ TRANSACTION ];
```

Expand All @@ -37,4 +37,4 @@ COMMIT TRANSACTION;
The following two options can be used at any point if a transaction must be cancelled without commiting the changes:

* [CANCEL](/docs/surrealql/statements/cancel) to manually cancel the transaction,
* [THROW](/docs/surrealql/statements/throw) to cancel a transaction with an optional error message. THROW is the only way to cancel a transaction based on a condition, such as inside an [IF..ELSE](/docs/surrealql/statements/ifelse) block.
* [THROW](/docs/surrealql/statements/throw) to cancel a transaction with an optional error message. THROW is the only way to cancel a transaction based on a condition, such as inside an [IF..ELSE](/docs/surrealql/statements/ifelse) block.
6 changes: 3 additions & 3 deletions src/content/doc-surrealql/statements/continue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The CONTINUE statement can be used to skip an iteration of a loop, like within t

### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
CONTINUE
```

Expand Down Expand Up @@ -66,7 +66,7 @@ FOR $data IN $weather {
IF $data IS NONE {
CONTINUE;
};
CREATE weather CONTENT $data;
};
```
```
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `CREATE` statement can be used to add a record to the database. If the recor
### Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
CREATE [ ONLY ] @targets
[ CONTENT @value
| SET @field = @value ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Defining an access method allows SurrealDB to grant access to resources using di

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE ACCESS [ OVERWRITE | IF NOT EXISTS ] @name
ON [ ROOT | NAMESPACE | DATABASE ]
TYPE [
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/access/jwt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Bear in mind that table and field permissions only apply to [record users](/docs

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE ACCESS [ OVERWRITE | IF NOT EXISTS ] @name
ON [ ROOT | NAMESPACE | DATABASE ]
TYPE JWT [ ALGORITHM @algorithm KEY @key | URL @url ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Record users allow SurrealDB to operate as a web database by offering mechanisms

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE ACCESS [ OVERWRITE | IF NOT EXISTS ] @name
ON DATABASE TYPE RECORD
[ SIGNUP @expression ]
Expand Down
4 changes: 2 additions & 2 deletions src/content/doc-surrealql/statements/define/analyzer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Since from '@components/Since.astro'

# `DEFINE ANALYZER` statement

In the context of a database, an analyzer plays a crucial role in text processing and searching. It is defined by its name, a set of tokenizers, and a collection of filters.
In the context of a database, an analyzer plays a crucial role in text processing and searching. It is defined by its name, a set of tokenizers, and a collection of filters.

The output of an analyzer can be experimented with by using the [`search::analyze()`](/docs/surrealql/functions/database/search#searchhighlight) function.

Expand All @@ -18,7 +18,7 @@ The output of an analyzer can be experimented with by using the [`search::analyz

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE ANALYZER [ OVERWRITE | IF NOT EXISTS ] @name [ TOKENIZERS @tokenizers ] [ FILTERS @filters ] [ COMMENT @string ]
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/database.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The `DEFINE DATABASE` statement allows you to instantiate a named database, enab

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE DATABASE [ OVERWRITE | IF NOT EXISTS ] @name [ COMMENT @string ]
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Events can be triggered after any change or modification to the data in a record

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE EVENT [ OVERWRITE | IF NOT EXISTS ] @name ON [ TABLE ] @table [ WHEN @expression ] THEN @expression [ COMMENT @string ]
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The `DEFINE FIELD` statement allows you to instantiate a named field on a table,

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE FIELD [ OVERWRITE | IF NOT EXISTS ] @name ON [ TABLE ] @table
[ [ FLEXIBLE ] TYPE @type ]
[ DEFAULT @expression ]
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/function.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Functions can be used to encapsulate logic that you want to reuse in multiple qu

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE FUNCTION [ OVERWRITE | IF NOT EXISTS ] fn::@name( [ @argument: @type ... ] ) {
[ @query ... ]
[ RETURN @returned ]
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: The DEFINE statement can be used to specify authentication access a

The DEFINE statement can be used to specify instructions to the schema such as authentication access and behaviour, global parameters, table configurations, table events, analyzers, and indexes.

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE [
NAMESPACE [ OVERWRITE | IF NOT EXISTS ] @name
| DATABASE [ OVERWRITE | IF NOT EXISTS ] @name
Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-surrealql/statements/define/indexes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Just like in other databases, SurrealDB uses indexes to help optimize query perf

## Statement syntax

```surql title="SurrealQL Syntax"
```syntax title="SurrealQL Syntax"
DEFINE INDEX [ OVERWRITE | IF NOT EXISTS ] @name ON [ TABLE ] @table [ FIELDS | COLUMNS ]
@fields
[ UNIQUE
Expand Down
Loading

0 comments on commit d734fb5

Please sign in to comment.