const db = .....collection('file').doc('doc.id');
my doc data:
{
"id":"12345678",
"name":"test",
"tables":[
{
"id":"12",
"name":"item 1",
"own":""
},
{
"id":"123",
"name":"item 2",
"own":""
},
{
"id":"1234",
"name":"item 3",
"own":""
}
]
}
a single object in the table array that I want to update:
{
"id":"123",
"name":"item 2",
"own":{
"n":"1",
"b":"3"
}
}
**** 文档中有一个数组叫做表,当这个数组有更新时,我只想替换更新的对象,而不是重写整个数组。
现在唯一的方法是发送和覆盖整个表数组,即使它是一个改变的对象。
这些都没有用:
db.set({tables:firebase.firestore.FieldValue.arrayUnion(table)})
db.set({tables:table}, {merge:true})
db.set({tables:[table]}, {merge:true})