Skip to content

Commit

Permalink
Update gates.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe authored Jan 28, 2024
1 parent cebe23e commit 6865a2a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,60 +85,60 @@ The following operators assist in evaluating documents:
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:

```
@{ 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:

```
@{ 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:

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

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:

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

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:

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

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 6865a2a

Please sign in to comment.