Firestore update all documents in collections

You can get all the documents in the collection, get their id's and perform updates using those id's:

db.collection("cities").get().then(function(querySnapshot) {
    querySnapshot.forEach(function(doc) {
        doc.ref.update({
            capital: true
        });
    });
});

Batch updates are nice but bare in mind that they are limited to 500 document updates per transaction. If this reset isn't done often maybe simplest approach is:

async function resetScores() {
  const collection = await db
    .collection("users")
    .get()
  collection.forEach(doc=> {
    doc.ref
      .update({
        score: 0
      })
  })
}

For some strange reason the accepted answer ( thehamzarocks ) wasn't working for me, none of the documents were updated. Maybe there's a bug in AngularFire2. Anyway, I decided to loop over the docs array of the QuerySnapshot instead of using its forEach method, and add each update to a batch queue. Batching bulk operations is also more efficient than sending a new update request for each update operation.

resetScore(): Promise<void> {
  return this.usersCollectionRef.ref.get().then(resp => {
    console.log(resp.docs)
    let batch = this.afs.firestore.batch();

    resp.docs.forEach(userDocRef => {
      batch.update(userDocRef.ref, {'score': 0, 'leadsWithSalesWin': 0, 'leadsReported': 0});
    })
    batch.commit().catch(err => console.error(err));
  }).catch(error => console.error(error))
}

I came across this post while searching for similar solutions. Firestore now has batched writes, which will update all documents in one go. This could be an ideal solution for fewer documents.

Updating @thehamzarocks's answer:

const batch = db.batch()

db.collection('cities').get().then(function(querySnapshot) {
    querySnapshot.forEach(function(doc) {
        const docRef = db.collection('cities').doc(doc.id)
        batch.update(docRef, { capital: true })
    });

    batch.commit();
});