I have a datastructure in the form of object structure . [![enter image description here][1]][1]
{ Invite1 { Amount: 10, PhoneNumber:9876543210, Status:"Pending" } Invite2 { Amount: 20, PhoneNumber:1234566789, Status:"Pending" } }
I have a condition when whose Invite(1,2,3) PhoneNumber matches with other document that invitee need to update the field as Status = true
When I try to update a field as Status = true It is updating at the end of the document.
Mycode need to update
var dbref = db1.collection('deyaPayUsers').doc(sendauthid).collection('Split').doc(sendauthid).collection('SentInvitations').doc(senderautoid);
var msg1 = receiverph + "" + status + " to pay $" + document.Amount;
var fulldoc = dbref.get()
.then(doc => {
if (!doc.exists) {
console.log('No such document');
} else {
console.log('Document data :', doc.data());
d1 = doc.data();
console.log("d1 is" + d1);
for (var k in d1) {
var p = d1[k].PhoneNumber;
console.log("ivitees phone" + p);
if (receiverph == p) // Here the condition is true of the invite phoneNumber then need to update
{
console.log("p" + PhoneNumber);
console.log("the phonenumber matches");
var updated = dbref.update({"Status":status});// Here It is updating at the endof the document
other Method to update
d1.Status = status; // In d1 I have the document data var setdata = dbref.set(d1);
Please if their is any approach help with me. Thanks