-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVPROD-11594 Document BSON Text Format
- Loading branch information
Jess Balint
committed
Nov 4, 2024
1 parent
c6f23a0
commit 593d340
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Extended JSON Query | ||
|
||
## Abstract | ||
|
||
Extended JSON query variation is a superset of Extended JSON. It is | ||
intended to be used for serializing queries that can be specified in | ||
the mongo shell. It supplements the Extended JSON syntax with support | ||
for the following features: | ||
|
||
- Trailing commas after the last value in an object | ||
|
||
- NumberLong values in quotation marks | ||
|
||
- Dates constructed with `new Date()` including an `ISODate` format | ||
|
||
- Regex pattern enclosed in slashes | ||
|
||
## Examples | ||
|
||
### Trailing Comma | ||
The following example shows an example of a JSON object with a trailing comma after the `b: 2` element. The trailing comma is supported only in objects, not in arrays. This is convenient when manually editing the text representation. | ||
```javascript | ||
{$match: | ||
{a: 1, | ||
b: 2,} | ||
} | ||
``` | ||
|
||
### Quoted NumberLong Value | ||
The EJSON syntax supports a `NumberLong()` constructor but the argument must not be quoted. The following example shows the quoted version of the number. | ||
```javascript | ||
{$match: | ||
{num: | ||
{$gt: NumberLong("123456789")} | ||
}} | ||
``` | ||
|
||
### Date Constructor | ||
The following example shows construction of a Date object with the date string represented in ISODate form. | ||
```javascript | ||
{$match: | ||
{dateField: | ||
{$lt: new Date("2019-10-23T08:58:17.868Z")} | ||
}} | ||
``` | ||
|
||
### Regex Pattern in Slashes | ||
The following example shows a regex value enclosed in slashes. This is consistent with the MQL syntax. | ||
```javascript | ||
{$regexFindAll: | ||
{input: \"$obj.obj.obj.obj.str\", | ||
regex: /transparent|Forward/} | ||
} | ||
``` |