Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe committed Jan 29, 2024
2 parents 7babfc3 + 09345c8 commit 7363896
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## RiScript: a scripting language for writers

RiScript is a micro-language designed for writers working in computational media. It runs in a variety of environments, including the browser, Node, Observable, P5.js, Android and others. RiScript primitives (choices, symbols, gates, transforms, etc.) can be used as part of any RiScript [grammar](https://rednoise.org/rita/reference/RiScript/grammar/) or executed directly using [evaluate()](https://rednoise.org/rita/reference/RiScript/grammar/). For more info, see this interactive [notebook](https://observablehq.com/@dhowe/riscript). RiScript is free/libre/open-source and integrates with [RiTa](https://rednoise.org/rita).
RiScript is a minor language designed for writers working in computational media. It runs in a variety of environments, including the browser, Node, Observable, P5.js, Android and others. RiScript primitives (choices, symbols, gates, transforms, etc) can be used as part of any RiScript [grammar](https://rednoise.org/rita/reference/RiScript/grammar/) or executed directly using [evaluate()](https://rednoise.org/rita/reference/RiScript/grammar/). For more info, see this interactive [notebook](https://observablehq.com/@dhowe/riscript). RiScript is free/libre/open-source and integrates with [RiTa](https://rednoise.org/rita).

### Installation

Expand Down
110 changes: 55 additions & 55 deletions docs/gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@

The following operators can be used in queries to compare values:

$eq: Values are equal
$ne: Values are not equal
$gt: Value is greater than another value
$gte: Value is greater than or equal to another value
$lt: Value is less than another value
$lte: Value is less than or equal to another value
$in: Value is matched within an array
@eq: Values are equal
@ne: Values are not equal
@gt: Value is greater than another value
@gte: Value is greater than or equal to another value
@lt: Value is less than another value
@lte: Value is less than or equal to another value
@in: Value is matched within an array

### Logical

The following operators logically combine multiple queries:

$and: Returns documents where both queries match
$or: Returns documents where either query matches
$nor: Returns documents where both queries fail to match
$not: Returns documents where the query does not match
@and: Returns documents where both queries match
@or: Returns documents where either query matches
@nor: Returns documents where both queries fail to match
@not: Returns documents where the query does not match

### Existence
The following operators can be used in queries the existence of fields:

$exists: symbols exists
not $exists: symbols doesn't exists
@exists: symbols exists
not @exists: symbols doesn't exists

### Evaluation

The following operators assist in evaluating documents:

$text: Performs a text search
$regex: Match symbol values with regular expressions
$where: Uses JS expressions to match fields
@text: Performs a text search
@regex: Match symbol values with regular expressions
@where: Uses JS expressions to match fields

### Operator Table

Expand All @@ -45,34 +45,34 @@ The following operators assist in evaluating documents:
</tr></thead>
<tbody>
<tr>
<td>$exists</td>
<td>@exists</td>
<td>does a symbol exist or not</td>
<td><code>@{ symbol: { $exists: true }</code></td>
<td><code>@{ symbol: { @exists: true }</code></td>
</tr>
<tr>
<td>$gt&nbsp;</td>
<td>@gt&nbsp;</td>
<td>with value greater than&nbsp;</td>
<td><code>@{ symbol: { $gt: 3 }</code></td>
<td><code>@{ symbol: { @gt: 3 }</code></td>
</tr>
<tr>
<td>$gte&nbsp;</td>
<td>@gte&nbsp;</td>
<td>with value greater or equal to</td>
<td><code>@{ symbol: { $gte: 3}</code></td>
<td><code>@{ symbol: { @gte: 3}</code></td>
</tr>
<tr>
<td>$lt&nbsp;</td>
<td>@lt&nbsp;</td>
<td>with value lesser than&nbsp;</td>
<td><code>@{ symbol: { $lt: 4}</code></td>
<td><code>@{ symbol: { @lt: 4}</code></td>
</tr>
<tr>
<td>$lte</td>
<td>@lte</td>
<td>with value lesser than or equal to</td>
<td><code>@{ symbol: { $lte: 4}</code></td>
<td><code>@{ symbol: { @lte: 4}</code></td>
</tr>
<tr>
<td>$regex</td>
<td>@regex</td>
<td>matches a regular expression pattern </td>
<td><code>@{ symbol: { $regex: /^USS\sE/ }})</code></td>
<td><code>@{ symbol: { @regex: /^USS\sE/ }})</code></td>
</tr>
</tbody>
</table>
Expand All @@ -82,63 +82,63 @@ The following operators assist in evaluating documents:
### Examples


The $exists operator will look for values that do or do not exist:
The @exists operator will look for values that do or do not exist:

```
@{ secret: { $exists: true}
@{ secret: { $exists: false}
@{ $secret: { @exists: true}
@{ $secret: { @exists: false}
```

The $eq and $ne operator will look for values match or do not match a value:
The @eq and @ne operator will look for values match or do not match a value:

```
@{ gender: { $ne: "male" } }
@{ name: { $eq: "kerri" } }
@{ $gender: { @ne: "male" } }
@{ $name: { @eq: "kerri" } }
```
The $in operator will look for equal values that match anything specified in an array:
The @in operator will look for equal values that match anything specified in an array:

```
@{ rank: { $in: [ "warrior", "scholar", "sage" ] } }
@{ $rank: { @in: [ "warrior", "scholar", "sage" ] } }
```

The $nin operator will look for equal values that do NOT match anything in an array:
The @nin operator will look for equal values that do NOT match anything in an array:

```
@{ rank: { $nin: [ "novice", "precept", "learner" ] } }
@{ $rank: { @nin: [ "novice", "precept", "learner" ] } }
```

The $all operator for matching ALL the elements in an array:
The @all operator for matching ALL the elements in an array:

```
@{ items: { $all: [ "bread", "nut butter", "jam" ] } }
@{ $items: { @all: [ "bread", "nut butter", "jam" ] } }
```

The $elemMatch operator for matching ANY element in an array:
The @elemMatch operator for matching ANY element in an array:

```
@{ items: { $elemMatch: { "crowbar", "key", "spell", "explosive" } } }
@{ $items: { @elemMatch: { "crowbar", "key", "spell", "explosive" } } }
```

The $and operator logically combines two or more queries:
The @and operator logically combines two or more queries:

```
@{ $and: [ { age: { $gt: 12 } }, { age: { $exists: true } } ] }
@{ @and: [ { age: { @gt: 12 } }, { $age: { @exists: true } } ] }
```
(equivalent to)
```
@{ { age: { $gt: 12, $exists: true } }
@{ { $age: { @gt: 12, @exists: true } }
```

The $or operator logically combines two or more queries:
The @or operator logically combines two or more queries:

```
@{ $or: [ { age: { $gt: 12 } }, { age: { $exists: false } } ] }
@{ @or: [ { $age: { @gt: 12 } }, { $age: { @exists: false } } ] }
```

The $nor operator logically combines two or more queries:
The @nor operator logically combines two or more queries:

```
@{ $nor: [ { age: { $lt: 12 } }, { age: { $exists: false } } ] }
@{ @nor: [ { $age: { @lt: 12 } }, { $age: { @exists: false } } ] }
```


Expand All @@ -147,34 +147,34 @@ The $nor operator logically combines two or more queries:
Search by regular expression:

```
@{ name: { $regex: /^M.*/}}
@{ $name: { @regex: /^M.*/}}
```

Regex options: case insensitive:

```
@{ name: { $regex: /^jan.*/, $options: "i"}}
@{ $name: { @regex: /^jan.*/, @options: "i"}}
```

Find by elements in array:
This matches documents that contain all of these array elements:

```
@{ protection: { $all: "helmet", "armor" }}
@{ $protection: { @all: "helmet", "armor" }}
```
(equivalent to)
```
{ $and: [ { protection: "helmet" }, { protection: "armor" } ] }
{ @and: [ { $protection: "helmet" }, { $protection: "armor" } ] }
```

Match on any element in the array:

```
@{ skills: "negotiation"}
@{ $skills: "negotiation"}
```

Match on inequality:

```
@{ strength: { $gt: 18 } }
@{ $strength: { @gt: 18 } }
```

0 comments on commit 7363896

Please sign in to comment.