How do I access and update a specific field in angular firestore:
It should be pretty easy task. You can use update function and pass the field name and value to update.
ex :
this.db.doc(`options/${id}`).update({rating:$rating}); //<-- $rating is dynamic
Is very simple (.collection) to declare the collection that u want to change (.doc) to specify the id of the document that u want to update and the in (.update) just put the update field that u want change it
constructor(private db: AngularFirestore) {}
this.db
.collection('options')
.doc('/' + 'mzx....')
.update({rating: value})
.then(() => {
console.log('done');
})
.catch(function(error) {
console.error('Error writing document: ', error);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With