Skip to content

Commit 89635c3

Browse files
committed
run snippets
1 parent a1d68bf commit 89635c3

File tree

105 files changed

+1475
-13
lines changed

Some content is hidden

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

105 files changed

+1475
-13
lines changed

snippets/firestore-next/test-firestore/and_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
and(field("rating").greaterThan(4), (field("price").lessThan(10)))
11+
and(field("rating").greaterThan(4), field("price").lessThan(10))
1212
.as("under10Recommendation")
1313
)
1414
);

snippets/firestore-next/test-firestore/functions_example.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ let results;
1010
// Type 1: Scalar (for use in non-aggregation stages)
1111
// Example: Return the min store price for each book.
1212
results = await execute(db.pipeline().collection("books")
13-
.select(
14-
field("current").logicalMinimum(["updated"]).as("price_min")
15-
)
13+
.select(field("current").logicalMinimum(field("updated")).as("price_min"))
1614
);
1715

1816
// Type 2: Aggregation (for use in aggregate stages)

snippets/firestore-next/test-firestore/max_logical_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
field("rating").logicalMaximum([1]).as("flooredRating")
11+
field("rating").logicalMaximum(1).as("flooredRating")
1212
)
1313
);
1414
// [END max_logical_function_modular]

snippets/firestore-next/test-firestore/min_logical_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
field("rating").logicalMinimum([5]).as("cappedRating")
11+
field("rating").logicalMinimum(5).as("cappedRating")
1212
)
1313
);
1414
// [END min_logical_function_modular]

snippets/firestore-next/test-firestore/not_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
(field("tags").arrayContains("nonfiction").not())
11+
field("tags").arrayContains("nonfiction").not()
1212
.as("isFiction")
1313
)
1414
);

snippets/firestore-next/test-firestore/or_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
or(field("genre").equal("Fantasy"), (field("tags").arrayContains("adventure")))
11+
or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure"))
1212
.as("matchesSearchFilters")
1313
)
1414
);

snippets/firestore-next/test-firestore/pagination_not_supported_preview.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,34 @@
66

77
// [START pagination_not_supported_preview_modular]
88
// Existing pagination via `startAt()`
9-
const q = // db.collection("cities").orderBy("population").startAt(1000000);
9+
const q =
1010
query(collection(db, "cities"), orderBy("population"), startAt(1000000));
1111

1212
// Private preview workaround using pipelines
13+
const pageSize = 2;
1314
const pipeline = db.pipeline()
1415
.collection("cities")
15-
.where(field("population").greaterThanOrEqual(1000000))
16-
.sort(field("population").descending());
16+
.select("name", "population", "__name__")
17+
.sort(field("population").descending(), field("__name__").ascending());
18+
19+
// Page 1 results
20+
let snapshot = await execute(pipeline.limit(pageSize));
21+
22+
// End of page marker
23+
const lastDoc = snapshot.results[snapshot.results.length - 1];
24+
25+
// Page 2 results
26+
snapshot = await execute(
27+
pipeline
28+
.where(
29+
or(
30+
and(
31+
field("population").equal(lastDoc.get("population")),
32+
field("__name__").greaterThan(lastDoc.ref)
33+
),
34+
field("population").lessThan(lastDoc.get("population"))
35+
)
36+
)
37+
.limit(pageSize)
38+
);
1739
// [END pagination_not_supported_preview_modular]

snippets/firestore-next/test-firestore/pipeline_where.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ results = await execute(db.pipeline().collection("books")
1313
);
1414

1515
results = await execute(db.pipeline().collection("books")
16-
.where(and(field("rating").equal(5), (field("published").lessThan(1900))))
16+
.where(and(field("rating").equal(5), field("published").lessThan(1900)))
1717
);
1818
// [END pipeline_where_modular]

snippets/firestore-next/test-firestore/xor_function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const result = await execute(db.pipeline()
99
.collection("books")
1010
.select(
11-
xor(field("tags").arrayContains("magic"), (field("tags").arrayContains("nonfiction")))
11+
xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction"))
1212
.as("matchesSearchFilters")
1313
)
1414
);
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-temp/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]

0 commit comments

Comments
 (0)