Append to an arary field in Firestore

后端 未结 2 590
面向向阳花
面向向阳花 2020-12-07 05:38

I\'m using Firebase and Vuejs to create an database element, which has object array inside.

That\'s how the object looks, and I want to add tasks through the form

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 06:34

    You can append an item to an array using FieldValue.arrayUnion() as described in the documentation. For example:

    // Atomically add a new region to the "regions" array field.
    washingtonRef.update({
        regions: firebase.firestore.FieldValue.arrayUnion("greater_virginia")
    });
    

提交回复
热议问题