Reputation: 31
The problem i can't seem to solve is:
I want to update a the value of a property in one of my collections lets say i have a collection "posts" and all the documents have a property(field) of votes which buy default is 1 and i want to update by one by every click.
collection doc fields
posts id1 votes: 1
Updating the value is would look something like this:
addVote(id){
this.postCollection.doc(id).update({
votes: 2
})
}
But how would I go about if I first want to check the the value of the property and then increase it by one for each click, the firebase documentation isn't much help.
Upvotes: 0
Views: 685
Reputation: 317467
Actually the documentation is of help here. You will need to use a transaction for changes that involve getting, modifying, and setting a value in a document.
Upvotes: 1