I want to add an Object
to an existing Array
in firestore.
I already have one Object
in the Array
, now I want to add the second Object
.
So I have created this code below to store data to firestore.
After I triggered the function the data in firestore
won't add a new Object
to the array
Code:
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
}
]
}
]
})