Update a field in an object in Firestore?

前端 未结 1 548
清歌不尽
清歌不尽 2021-02-18 22:11

This is the example provided in the documentation to update a field within a nested object in firebase.

var frankDocRef = db.collection(\"users\").doc(\"frank\"         


        
相关标签:
1条回答
  • 2021-02-18 22:57

    To add an entry to a set (a Javascript Object), use DocumentReference.update:

    db.collection("users").doc("frank").update({
      "favorites.firebase": "Help")}
    })
    

    will result in

    favorites: { food: "Pizza", color: "Blue", subject: "recess", firebase: "Help" }
    
    0 讨论(0)
提交回复
热议问题