I'm trying to update a field in a firestore array.
I have a document in a collection that goes like this:
started: agoust,
ends: november,
positions: [
{
player: 'user2',
points: 6
},
{
player: 'user3',
points: 3
},
{
player: 'user4',
points: 0
},
{
player: 'user1',
points: 1
},
]
I want to update only the points of the current user (user1) and i cant find the answer.
Ive tried something like this:
await firebase
.firestore()
.collection('tournaments')
.doc(bet?.id)
.update({
positions: firebase.firestore.FieldValue.arrayUnion({
player: user?.username,
points: 0
})
})
This doesnt works, it clears all the array