我目前正在尝试Firestore,而且我被困在一件非常简单的事情上:“更新数组(又名一个子文档)”。如何用Firestore更新“对象数组”?
我的数据库结构非常简单。例如:
proprietary: "John Doe"
sharedWith:
[
{who: "[email protected]", when:timestamp}
{who: "[email protected]", when:timestamp}
]
我试图(没有成功)将新记录推入shareWith
对象数组。
我已经试过:
// With SET
firebase.firestore()
.collection('proprietary')
.doc(docID)
.set(
{ sharedWith: [{ who: "[email protected]", when: new Date() }] },
{ merge: true }
)
// With UPDATE
firebase.firestore()
.collection('proprietary')
.doc(docID)
.update({ sharedWith: [{ who: "[email protected]", when: new Date() }] })
无工作。 这些查询覆盖我的数组。
答案可能很简单,但我could'nt找到它...
感谢
这太令人沮丧了...但是,谢谢让我知道我不会发疯。 – ItJustWerks
这是一个很大的缺点,谷歌必须尽快解决它。 –