【发布时间】:2018-08-16 18:00:55
【问题描述】:
我想将 Object 添加到 firestore 中现有的 Array。
我已经在Array 中有一个Object,现在我想添加第二个Object。
所以我在下面创建了这段代码来将数据存储到 Firestore。
触发函数后,firestore 中的数据不会向数组中添加新的Object
代码:
let docId = `${this.currentUser.uid}`
fb.usersCollection.doc(docId).update({
userId: this.currentUser.uid,
posts: [
{
createdOn: this.postDetails.createdOn,
content: this.postDetails.content,
image: this.postDetails.image,
comments: this.postDetails.comments,
likes: this.postDetails.likes,
tags: this.model,
userData: [
{ userName: this.userProfile.name,
userId: this.currentUser.uid,
userImage: this.userProfile.userImage
}
]
}
]
})
【问题讨论】:
标签: javascript firebase google-cloud-firestore