Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4738eab

Browse files
authored
Add count query snippets (#303)
* Add count query snippets* execute snippet* upaate non-breaking changes* update node modules to latest
1 parentf1869ee commit4738eab

File tree

3 files changed

+5981
-5535
lines changed

3 files changed

+5981
-5535
lines changed

‎firestore/main/index.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,25 @@ async function deleteQueryBatch(db, query, resolve) {
982982

983983
// [END firestore_data_delete_collection]
984984

985+
asyncfunctioncountAggregateCollection(db){
986+
// [START count_aggregation_collection]
987+
constcollectionRef=db.collection('cities');
988+
constsnapshot=awaitcollectionRef.count().get();
989+
990+
console.log(snapshot.data.count);
991+
// [END count_aggregation_collection]
992+
}
993+
994+
asyncfunctioncountAggregateQuery(db){
995+
// [START count_aggregation_query]
996+
constcollectionRef=db.collection('cities');
997+
constquery=collectionRef.where('state','==','CA');
998+
constsnapshot=awaitcollectionRef.count().get();
999+
1000+
console.log(snapshot.data.count);
1001+
// [END count_aggregation_query]
1002+
}
1003+
9851004
// ============================================================================
9861005
// MAIN
9871006
// ============================================================================
@@ -1165,4 +1184,12 @@ describe('Firestore Smoketests', () => {
11651184
it('should find all museums when querying a collection group',()=>{
11661185
returncollectionGroupQuery(db);
11671186
});
1187+
1188+
it('should count the number of documents in a collection',()=>{
1189+
returncountAggregateCollection(db);
1190+
});
1191+
1192+
it('should count the number of documents in a filtered query',()=>{
1193+
returncountAggregateQuery(db);
1194+
});
11681195
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp