Skip to content

Commit 0183b3b

Browse files
committed
Rearranged page order and updated example snippet formatting
1 parent 8180c37 commit 0183b3b

File tree

29 files changed

+844
-341
lines changed

29 files changed

+844
-341
lines changed

examples/node/v12/__tests__/realm-query-language.test.ts

Lines changed: 165 additions & 97 deletions
Large diffs are not rendered by default.

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.backlinks-aggregate-operators.ts.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.. code-block:: typescript
22
3-
// Find items that belong to a project with a quota
4-
// less than 10 (using '@links').
3+
// Find items that belong to a project with a quota less than 10
4+
// (using '@links.<ObjectType>.<PropertyName>').
55
"@links.Project.items.quota < 10"
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
.. code-block:: typescript
22
3-
// Find items where ANY project that references the item
4-
// has a quota greater than 10.
5-
"ANY @links.Project.items.quota > 10"
6-
// Find items where ALL projects that reference the item
7-
// have a quota less than 5.
8-
"ALL @links.Project.items.quota < 5"
3+
// Find items where no project that references the item
4+
// has a quota greater than 10.
5+
"NONE @links.Project.items.quota > 10"
6+
7+
// Find items where all projects that reference the item
8+
// have a quota less than 5.
9+
"ALL @links.Project.items.quota < 5"
10+
11+
// Find items that are referenced by multiple projects.
12+
"projects.@count > 1"
13+
14+
// Find items that are not referenced by any project.
15+
"@links.Project.items.@count == 0"
16+
17+
// Find items that belong to a project where the average item has
18+
// been worked on for at least 10 minutes
19+
20+
21+
// Find items that are not referenced by another
22+
// object of any type (backlink count is 0).
23+
"@links.@count == 0"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.. code-block:: typescript
22
33
// Find items that belong to a project with a quota greater than 10
4+
// through the Item object's `projects` property
45
// (using 'LinkingObjects').
56
"projects.quota > 10"
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.. code-block:: typescript
22
3-
// Find items with a `priority` greater than 3.
4-
"2 * priority > 6" // `priority > 3`
5-
"priority >= 2 * (2 - 1) + 2" // `priority >= 4`
3+
// Evaluate against an item's `priority` property value:
4+
"2 * priority > 6" // resolves to `priority > 3`
5+
"priority >= 2 * (2 - 1) + 2" // resolves to `priority >= 4`
6+
7+
// Evaluate against multiple object property values:
8+
"progressMinutes * priority == 90"

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.comparison-operators.ts.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// Compare `priority` values against a threshold value.
44
"priority > $0", 5
55
6-
// Compare `progressMinutes` values against a threshold value.
7-
"progressMinutes > $0", 120
8-
96
// Compare `assignee` values to `null` value.
107
"assignee == $0", null
118

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.date-parameterized-query.ts.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
// Find to-do items completed before today's date.
44
"dateCompleted < $0", today
55
6-
// Find to-do items completed this year until today.
6+
// Find to-do items completed between the start of the year
7+
// until today.
78
"dateCompleted > $0 AND dateCompleted < $1", thisYear, today
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.. code-block:: typescript
22
3+
// Find projects whose `projectLocation` property contains
4+
// an embedded Address object with a specific zip code.
35
"projectLocation.address.zipcode == 10019"
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
.. code-block:: typescript
22
3-
// Find `comments` dictionary properties with key 'status'.
3+
// Find projects whose `comments` dictionary property
4+
// have a key of 'status'.
45
"comments.@keys == $0", "status"
56
6-
// Find `comments` dictionary properties with key 'status'
7-
// and value 'On track'.
8-
"comments['status'] == $0", "On track"
9-
// Find `comments` dictionary properties with
10-
// more than one key-value pair.
11-
"comments.@count > $0", 1
7+
// Find projects whose `comments` dictionary property
8+
// have a 'status' key with a value that ends in 'track'.
9+
"comments['status'] LIKE $0", "*track"
1210
13-
// Find `comments` dictionary properties where ANY
14-
// values are of type 'string`.
15-
"ANY comments.@type == 'string'"
16-
"comments.@type == 'string'" // (Equivalent - ANY is implied.)
11+
// Find projects whose `comments` dictionary property
12+
// have more than one key-value pair.
13+
"comments.@count > $0", 1
1714
18-
// Find `comments` dictionary properties where ALL
19-
// values are of type 'int'.
20-
"ALL comments.@type == 'int'"
15+
// Find projects whose `comments` dictionary property
16+
// contains only values of type 'string'.
17+
"ALL comments.@type == 'string'"
2118
22-
// Find `comments` dictionary properties where NO
23-
// values are of type 'int'.
19+
// Find projects whose `comments` dictionary property
20+
// contains no values of type 'int'.
2421
"NONE comments.@type == 'int'"
25-
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. code-block:: typescript
2+
3+
// Find projects whose `items` list property contains
4+
// an Item object with a specific name.
5+
"items[0].name == 'Approve project plan'"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. code-block:: typescript
2+
3+
"assignee == ANY { $0, $1 }", "Alex", "Ali"
4+
5+
"assignee == { $0, $1 }", "Alex", "Ali" // Equivalent (ANY is implied.)
6+
7+
"assignee NONE { 'Alex', 'Ali' }" // Equivalent to != ANY.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.. code-block:: typescript
22
3+
// Find an item with the specified ObjectId value
4+
// in the `items` collection.
35
"oid(631a072f75120729dc9223d9) IN items._id"

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.list-comparisons-parameterized.ts.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
new BSON.ObjectId("631a0737c98f89f5b81cd24d"),
66
new BSON.ObjectId("631a073c833a34ade21db2b2"),
77
];
8+
// Find items with an ObjectId value matching any value in the
9+
// parameterized list.
810
const parameterizedQuery = realm.objects(Item).filtered("_id IN $0", ids);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.. code-block:: typescript
22
3+
// Find items with a priority value matching
4+
// any value in the static list.
35
"priority IN {0, 1, 2}"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.. code-block:: typescript
22
3-
"assignee == nil"
3+
"assignee == nil"
4+
5+
// 'null' maps to the SDK language's null pointer
6+
"assignee == $0", null

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.oid-literal.ts.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
.. code-block:: typescript
22
3-
"_id == oid(6001c033600510df3bbfd864)"
3+
// Find an item whose `_id` matches the ObjectID
4+
// value passed to 'oid()'.
5+
"_id == oid(6001c033600510df3bbfd864)"
6+
7+
// Find an item whose `_id` matches the ObjectID
8+
// passed as a parameterized query argument.
9+
"_id == $0", oidValue
10+
11+
// Find an item whose `id` matches the UUID value
12+
// passed to 'uuid()'.
13+
"id == uuid(d1b186e1-e9e0-4768-a1a7-c492519d47ee)"
14+
15+
16+
// Find an item whose `_id` matches the UUID
17+
// passed as a parameterized query argument.
18+
"id == $0", uuidValue

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.rql-fts.ts.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
// Find items with 'write' but not 'tests' in the name.
88
"name TEXT $0", "write -tests"
99
10-
// Use '*' to match any suffix characters:
11-
// Find items starting with 'wri-'.
10+
// Use '*' to match any characters after a prefix:
11+
// Find items with a name that starts with 'wri'.
1212
"name TEXT $0", "wri*"

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.set-operators.ts.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Find projects with no complete items.
44
"NONE items.isComplete == $0", true
55
6-
// Find projects that contain an item with priority 10.
7-
"ANY items.priority == $0", 10
6+
// Find projects that contain any item with priority 10.
7+
"items.priority == $0", 10 // (ANY operator is implied.)
88
99
// Find projects that only contain completed items.
1010
"ALL items.isComplete == $0", true
@@ -13,5 +13,6 @@
1313
// either Alex or Ali.
1414
"ANY items.assignee IN { $0 , $1 }", "Alex", "Ali"
1515
16-
// Projects with no items assigned to either Alex or Ali.
16+
// Find projects with no items assigned to either
17+
// Alex or Ali.
1718
"NONE items.assignee IN { $0 , $1 }", "Alex", "Ali"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. code-block:: typescript
2+
3+
// 1. Sorts by highest priority.
4+
// 2. Returns the first item.
5+
// 3. Remove duplicate names (N/A because a single
6+
// item is always considered distinct).
7+
"assignee == null SORT(priority ASC) LIMIT(1) DISTINCT(name)"
8+
9+
// 1. Removes any duplicates by name.
10+
// 2. Sorts by highest priority.
11+
// 3. Returns the first item.
12+
"assignee == null DISTINCT(name) SORT(priority ASC) LIMIT(1)"
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
.. code-block:: typescript
22
3-
"assignee == 'Ali' SORT(priority DESC) DISTINCT(name) LIMIT(5)"
3+
// Find incomplete items, sort by `priority`
4+
// in descending order, then sort equal `priority`
5+
// values by `progressMinutes` in ascending order.
6+
"isComplete == false SORT(priority DESC, progressMinutes ASC)"
7+
8+
// Find high priority items, then remove from the results
9+
// any items with duplicate `name` AND `assignee` values.
10+
"priority >= 5 DISTINCT(name, assignee)"
11+
// Find in-progress items, then return the first 10 results.
12+
"progressMinutes > 0 && isComplete != true LIMIT(10)"
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
.. code-block:: typescript
22
3-
// Find projects whose name starts with the letter 'e'
4-
// (case-insensitive).
5-
"name BEGINSWITH[c] $0", "e"
3+
// Find projects whose name starts with 'E' or 'e'
4+
// (case-insensitive).
5+
"name BEGINSWITH[c] $0", "E"
66
7-
// Find projects whose name contains the letters 'ie'
8-
// (case-sensitive).
9-
"name CONTAINS $0", "ie"
7+
// Find projects whose name contains 'ie'
8+
// (case-sensitive).
9+
"name CONTAINS $0", "ie"
10+
11+
// Find items where the assignee name is lexicographically
12+
// between 'Ali' and 'Chris' (case-sensitive).
13+
"assignee BETWEEN { $0 , $1 }", "Ali", "Chris"
14+
15+
// Find projects where the street address is lexicographically
16+
// greater than '123 Main St' (case-sensitive).
17+
"projectLocation.address.street > $0", "123 Main St"

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.subquery-count.ts.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
.. code-block:: typescript
22
3-
// Find projects with incomplete to-do items assigned to Alex.
4-
"SUBQUERY(items, $item, $item.isComplete == false AND $item.assignee == 'Alex').@count > 0"
3+
// Find projects with incomplete items with 'Demo' in the name.
4+
"SUBQUERY(items, $item, $item.isComplete == false AND $item.name CONTAINS[c] 'Demo').@count > 0"
5+
6+
// Find projects where the number of completed items
7+
// is greater than or equal to the project's `quota` property.
8+
"SUBQUERY(items, $item, $item.isComplete == true).@count >= quota"
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
.. code-block:: typescript
22
3-
"mixedType.@type == 'string'"
3+
// Find projects with an `additionalInfo` property of
4+
// string type.
5+
"additionalInfo.@type == 'string'"
46
5-
"mixedType.@type == 'bool'"
7+
// Find projects with an `additionalInfo` property of
8+
// `collection` type, which matches list or dictionary types.
9+
"additionalInfo.@type == 'collection'"
10+
11+
// Find projects with an `additionalInfo` property of
12+
// list type, where any list element is of type 'bool'.
13+
"additionalInfo[*].@type == 'bool'"

source/examples/generated/node/v12/formatted/realm-query-language.test.snippet.uuid.ts.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

source/examples/generated/node/v12/formatted/rql-data-models.snippet.rql-data-models.ts.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
quota?: number;
3434
comments?: Realm.Dictionary<string>;
3535
projectLocation?: Office;
36+
additionalInfo!: Realm.Mixed;
3637
3738
static schema: ObjectSchema = {
3839
name: "Project",
@@ -43,6 +44,7 @@
4344
quota: "int?",
4445
comments: "string?{}",
4546
projectLocation: "Office?",
47+
additionalInfo: "mixed",
4648
},
4749
primaryKey: "_id",
4850
};

0 commit comments

Comments
 (0)