This is my code:
function saveID(sender_psid,complete){
let data = new Object();
data.TASK= complete;
data.ID = sender_psid;
db.collection('users').add(data);
}
Right now a new document is created every time the field complete is updated. I want to update the value of complete in firestore instead of creating a new document each time.
If you want to update an existing document, build a DocumentReference that points to the document to update, and use its update() method to indicate which fields should be changed. The documentation goes over this and gives a code sample:
var cityRef = db.collection('cities').doc('DC');
// Set the 'capital' field of the city
var updateSingle = cityRef.update({ capital: true });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.