Which code do I need to create an Array in Firebase Firestore
?
I want to store userDetails
:
userName: this.userProfile.name,
userImage: this.userProfile.image,
userId: this.userProfile.userId
as an Array inside Firestore
Vue
component:
...
data () {
return {
postDetails: {
createdOn: new Date(),
content: '',
userId: null,
image: null,
comments: 0,
likes: 0,
userDetails: []
}
userData: [
{ userName: this.userProfile.name },
{ userImage: this.userProfile.image},
{ userId: this.userProfile.userId }
}
},
methods: {
createPost () {
fb.postsCollection.add({
createdOn: this.postDetails.createdOn,
content: this.postDetails.content,
userId: this.currentUser.uid,
image: this.postDetails.image,
comments: this.postDetails.comments,
likes: this.postDetails.likes
userData: this.userData
}).then(ref => {
this.post.content = ''
this.$router.push('/dashboard')
}).catch(err => {
console.log(err)
})
}
}