Skip to content

Commit dfa77bf

Browse files
committed
fix includecode typos and run snippets
1 parent 42b7091 commit dfa77bf

File tree

138 files changed

+1777
-9
lines changed

Some content is hidden

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

138 files changed

+1777
-9
lines changed

firestore-next/test.firestore.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ describe("firestore-pipelines", () => {
14671467
// https://cloud.google.com/firestore/docs/pipeline/stages/transformation/unnest
14681468

14691469
async function unnestSyntaxExample() {
1470+
// [START unnest_syntax]
14701471
const userScore = await execute(db.pipeline()
14711472
.collection("users")
14721473
.unnest(field("scores").as("userScore"), /* index_field= */ "attempt"));
@@ -1499,6 +1500,7 @@ describe("firestore-pipelines", () => {
14991500
}
15001501

15011502
async function unnestNonArrayExample() {
1503+
// [START unnest_nonarray]
15021504
const userScore = await execute(db.pipeline()
15031505
.collection("users")
15041506
.unnest(field("scores").as("userScore"), /* index_field= */ "attempt"));
@@ -1857,7 +1859,7 @@ describe("firestore-pipelines", () => {
18571859
// [START collection_input_syntax]
18581860
const results = await execute(db.pipeline()
18591861
.collection("cities/SF/departments"));
1860-
// [END Collection_input_syntax]
1862+
// [END collection_input_syntax]
18611863
}
18621864

18631865
async function collectionInputExampleData() {
@@ -1925,7 +1927,7 @@ describe("firestore-pipelines", () => {
19251927
const results = await execute(db.pipeline()
19261928
.collectionGroup("departments")
19271929
.sort(field("employees").ascending()));
1928-
// [END collection_group_inputi]
1930+
// [END collection_group_input]
19291931
}
19301932

19311933
// https://cloud.google.com/firestore/docs/pipeline/stages/input/database
@@ -1995,6 +1997,7 @@ describe("firestore-pipelines", () => {
19951997
// https://cloud.google.com/firestore/docs/pipeline/stages/transformation/aggregate
19961998

19971999
async function aggregateSyntaxExample() {
2000+
// [START aggregate_syntax]
19982001
const cities = await execute(db.pipeline()
19992002
.collection("cities")
20002003
.aggregate(

firestore-temp/test.firestore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ describe("firestore-pipelines", () => {
557557
const results = await db.pipeline()
558558
.collection("cities/SF/departments")
559559
.execute();
560-
// [END Collection_input_syntax]
560+
// [END collection_input_syntax]
561561
}
562562

563563
async function collectionInputExampleData() {
@@ -625,7 +625,7 @@ describe("firestore-pipelines", () => {
625625
.collectionGroup("departments")
626626
.sort(field("employees").ascending())
627627
.execute();
628-
// [END collection_group_inputi]
628+
// [END collection_group_input]
629629
}
630630

631631
// https://cloud.google.com/firestore/docs/pipeline/stages/input/database
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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_fields_nesting_modular]
8+
const results = await execute(db.pipeline()
9+
.collection("users")
10+
.addFields(field("address.city").toLower().as("address.city")));
11+
// [END add_fields_nesting_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 add_fields_overlap_modular]
8+
const results = await execute(db.pipeline()
9+
.collection("users")
10+
.addFields(field("age").abs().as("age"))
11+
.addFields(field("age").add(10).as("age")));
12+
// [END add_fields_overlap_modular]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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_fields_syntax_modular]
8+
const results = await execute(db.pipeline()
9+
.collection("users")
10+
.addFields(field("firstName").stringConcat(" ", field("lastName")).as("fullName")));
11+
// [END add_fields_syntax_modular]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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_data_modular]
8+
await setDoc(doc(collection(db, "cities"), "SF"), {name: "San Francisco", state: "CA", country: "USA", population: 870000});
9+
await setDoc(doc(collection(db, "cities"), "LA"), {name: "Los Angeles", state: "CA", country: "USA", population: 3970000});
10+
await setDoc(doc(collection(db, "cities"), "NY"), {name: "New York", state: "NY", country: "USA", population: 8530000});
11+
await setDoc(doc(collection(db, "cities"), "TOR"), {name: "Toronto", state: null, country: "Canada", population: 2930000});
12+
await setDoc(doc(collection(db, "cities"), "MEX"), {name: "Mexico City", state: null, country: "Mexico", population: 9200000});
13+
// [END aggregate_data_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 aggregate_group_complex_modular]
8+
const cities = await execute(db.pipeline()
9+
.collection("cities")
10+
.aggregate({
11+
accumulators: [
12+
sum("population").as("totalPopulation")
13+
],
14+
groups: [field("state").equal(null).as("stateIsNull")]
15+
}));
16+
// [END aggregate_group_complex_modular]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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_group_example_modular]
8+
const cities = await execute(db.pipeline()
9+
.collection("cities")
10+
.aggregate({
11+
accumulators: [
12+
countAll().as("numberOfCities"),
13+
maximum("population").as("maxPopulation")
14+
],
15+
groups: ["country", "state"]
16+
}));
17+
// [END aggregate_group_example_modular]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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_group_syntax_modular]
8+
const result = await execute(db.pipeline()
9+
.collectionGroup("cities")
10+
.aggregate({
11+
accumulators: [
12+
countAll().as("cities"),
13+
field("population").sum().as("totalPopulation")
14+
],
15+
groups: [field("location.state").as("state")]
16+
}));
17+
// [END aggregate_group_syntax_modular]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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_syntax_modular]
8+
const cities = await execute(db.pipeline()
9+
.collection("cities")
10+
.aggregate(
11+
countAll().as("total"),
12+
average("population").as("averagePopulation")
13+
));
14+
// [END aggregate_syntax_modular]

0 commit comments

Comments
 (0)