Skip to content

Commit fbdc32b

Browse files
committed
Add count query snippet
1 parent 7403e77 commit fbdc32b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

firestore-next/test.firestore.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,17 @@ describe("firestore", () => {
11581158
});
11591159
});
11601160

1161+
describe("aggregate queries", () => {
1162+
it("should fetch the count of documents in a collection", async () => {
1163+
// [START count_aggregate_query]
1164+
const coll = collection(db, "games/chess/players");
1165+
const query = query(coll, where("online", "==", true));
1166+
const snapshot = await getCountFromServer(query);
1167+
console.log('count: ', snapshot.data().count);
1168+
// [END count_aggregate_query]
1169+
});
1170+
});
1171+
11611172
// TODO: Break out into separate file
11621173
describe("solution-aggregation", () => {
11631174
it("should update a restaurant in a transaction #UNVERIFIED", async () => {

0 commit comments

Comments
 (0)