DocumentReference tweetDocProfile = tweetsRef.doc(tweet.authorId).collection('userTweets').doc(tweet.id);
tweetDocProfile.get().then((doc) {
int likes = doc.get('likes');
tweetDocProfile.update({'likes' : likes+1});
});
Value of likes
is not updating in Firebase, I am able to update it in code but update is not working I guess
2
Answers
Try this!
try this way, it is safer to modify,
It saves you a get request and the script internally uses a transaction so it doesn’t overwrite the data.