Skip to content

Commit 822bea8

Browse files
committed
run snippets and fix some typos
1 parent 01848bd commit 822bea8

File tree

98 files changed

+1435
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1435
-6
lines changed

firestore-next/test.firestore.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const cityConverter = {
3535
describe("firestore", () => {
3636
const { Firestore } = require("firebase/firestore");
3737

38-
let app;
39-
let db;
38+
/** @type {Firestore} */
39+
let db;
40+
let app;
4041

4142
before(() => {
4243
const { initializeApp } = require("firebase/app");
@@ -1346,8 +1347,8 @@ describe("firestore-pipelines", () => {
13461347
.where(field("population").greaterThan(100000))
13471348
// Step 3: Sort the remaining documents
13481349
.sort([field("name").ascending()])
1349-
// Step 4: Return the top 10. Note applying the limit earlier in the pipeline would have
1350-
// unintentional results.
1350+
// Step 4: Return the top 10. Note applying the limit earlier in the
1351+
// pipeline would have unintentional results.
13511352
.limit(10);
13521353
// [END pipeline_concepts]
13531354
console.log(pipeline);
@@ -1726,7 +1727,7 @@ describe("firestore-pipelines", () => {
17261727
// { identifier: 1, neighbors: [ "Alice", "Cathy" ], unnestedNeighbors: "Alice", index: 0 }
17271728
// { identifier: 1, neighbors: [ "Alice", "Cathy" ], unnestedNeighbors: "Cathy", index: 1 }
17281729
// { identifier: 3, neighbors: "Bob", index: null}
1729-
// [END unneest_edge_cases]
1730+
// [END unnest_edge_cases]
17301731
console.log(results);
17311732
}
17321733

@@ -2083,7 +2084,7 @@ describe("firestore-pipelines", () => {
20832084
}
20842085

20852086
async function lessThanOrEqualToFunction() {
2086-
// START less_or_equal]
2087+
// [START less_or_equal]
20872088
const result = await db.pipeline()
20882089
.collection("books")
20892090
.select([field("rating").lessThanOrEqual(2).as("hasBadRating")])
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START add_function_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([field("soldBooks").add(field("unsoldBooks")).as("totalBooks")])
11+
.execute();
12+
// [END add_function_modular]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START aggregate_distinct_modular]
8+
const results = await db.pipeline()
9+
.collection("books")
10+
.distinct([
11+
field("author").toUpper().as("author"),
12+
field("genre")
13+
])
14+
.execute();
15+
// [END aggregate_distinct_modular]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START aggregate_groups_modular]
8+
const results = await db.pipeline()
9+
.collection("books")
10+
.aggregate([
11+
field("rating").average().as("avg_rating")
12+
], {
13+
groups: [
14+
field("genre")
15+
]
16+
})
17+
.execute();
18+
// [END aggregate_groups_modular]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START and_function_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([
11+
and(field("rating").greaterThan(4), (field("price").lessThan(10)))
12+
.as("under10Recommendation")
13+
])
14+
.execute();
15+
// [END and_function_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START array_concat_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([field("genre").arrayConcat([field("subGenre")]).as("allGenres")])
11+
.execute();
12+
// [END array_concat_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START array_contains_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([field("genre").arrayContains(constant("mystery")).as("isMystery")])
11+
.execute();
12+
// [END array_contains_modular]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START array_contains_all_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([
11+
field("genre")
12+
.arrayContainsAll([constant("fantasy"), constant("adventure")])
13+
.as("isFantasyAdventure")
14+
])
15+
.execute();
16+
// [END array_contains_all_modular]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START array_contains_any_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([
11+
field("genre")
12+
.arrayContainsAny([constant("fantasy"), constant("nonfiction")])
13+
.as("isMysteryOrFantasy")
14+
])
15+
.execute();
16+
// [END array_contains_any_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START array_length_modular]
8+
const result = await db.pipeline()
9+
.collection("books")
10+
.select([field("genre").arrayLength().as("genreCount")])
11+
.execute();
12+
// [END array_length_modular]

0 commit comments

Comments
 (0)