Firestore update all documents in collections

后端 未结 4 752
执笔经年
执笔经年 2020-11-29 11:04

I have a firestore collections named users, each users have a generated id with a field score :

users 
    0e8X3VFL56rHBxxgkYOW
        score : 4
    3SeDjr         


        
4条回答
  •  执笔经年
    2020-11-29 11:50

    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
            });
        });
    });
    

提交回复
热议问题