Skip to content

Instantly share code, notes, and snippets.

@JoeArmani
Last active January 17, 2024 14:20
Show Gist options
  • Select an option

  • Save JoeArmani/4a292f59beb9358bdc2d1c43ad4f8fb1 to your computer and use it in GitHub Desktop.

Select an option

Save JoeArmani/4a292f59beb9358bdc2d1c43ad4f8fb1 to your computer and use it in GitHub Desktop.
Using Firestore's Count Aggregator
const countDocs = async () => {
try {
const shippedBoxesCountSnapshot = await db.collection('boxes')
.where('145971562', '==', 353358909)
.where('789843387', '==', 13)
.count()
.get();
console.log('shippedBoxesCountSnapshot', shippedBoxesCountSnapshot);
console.log('count:', shippedBoxesCountSnapshot.data().count);
} catch (error) {
console.error("Error updating boxes collection: ", error);
}
}
countDocs();
@anthonypetersen
Copy link

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment