I retrieved the object type data from the firestore and stored in a variable document
{ Invite1: { Amount: 25, PhoneNumber: 917995954482 },
Invite2: { Amount: 25, PhoneNumber: 918179405940 },
Invite3: { Amount: 25, PhoneNumber: 918179441493 },
Invite4: { Amount: 25, PhoneNumber: 918309097608 } }
Now, I need to get the PhoneNumber from all the Invite. After getting all the phone numbers into an array I need to check these Phone numbers already exists in database path like
/deyaPayUsers // collection
{authid} //document
Name: abcd
Phone Number: 987654321
Just try this :)
var phoneNumbers = [];
var data = { Invite1: { Amount: 25, PhoneNumber: 917995954482 },
Invite2: { Amount: 25, PhoneNumber: 918179405940 },
Invite3: { Amount: 25, PhoneNumber: 918179441493 },
Invite4: { Amount: 25, PhoneNumber: 918309097608 } }
for(var k in data){
phoneNumbers.push(data[k].PhoneNumber);
}
Try
var phoneNumbers = Object.keys(document).map(item => document[item].PhoneNumber);
Edited to take document as an object instead of array.
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.