firebase cloud functions iterate over a collection

You need to run get query, not sure what is admin here, but you can do like this:

const citiesRef = db.collection('cities'); // pass your collection name
const snapshot = await citiesRef.where('capital', '==', true).get(); // query collection
if (snapshot.empty) {
  console.log('No matching documents.');

snapshot.forEach(doc => {
  console.log(, '=>',;

You can check this link, for more details.

Also, I would suggest you go through this link to correctly set up the cloud function for firestore if there are any issues with it.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top