This is my code:
function saveID(sender_psid,plete){
let data = new Object();
data.TASK= plete;
data.ID = sender_psid;
db.collection('users').add(data);
}
Right now a new document is created every time the field plete is updated. I want to update the value of plete in firestore instead of creating a new document each time.
This is my code:
function saveID(sender_psid,plete){
let data = new Object();
data.TASK= plete;
data.ID = sender_psid;
db.collection('users').add(data);
}
Right now a new document is created every time the field plete is updated. I want to update the value of plete in firestore instead of creating a new document each time.
Share Improve this question edited Jul 10, 2018 at 19:25 Doug Stevenson 319k36 gold badges456 silver badges473 bronze badges asked Jul 10, 2018 at 19:15 RashikRashik 1,1642 gold badges16 silver badges36 bronze badges1 Answer
Reset to default 6If 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 });
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745097141a4611047.html
评论列表(0条)