I using firebase my collection and document look like
Collections : Users => Document : UUID (UKLDKHD...) include field :
{
phone_number : 123456
}
In collections users , i have 10 document
Because firebase not support query with undefined , so i write code get all document and filter it :
This is my code
let phoneNumber = await getPhone().where('phone_number', '==', req.phone_number).get();
if (!phoneNumber.empty) {
await handleLogic(phoneNumber)
}
async function handleLogic(phoneNumber) {
phoneNumber.docs.map(async doc => {
if (doc.exists && doc.data().deteted_at === undefined) {
return doc.data
}
}
)
}
But when i call function await handleLogic(phoneNumber) , it return me undefined. I can't understand why ? But when i put log in function
phoneNumber.docs.map(async doc => {
if (doc.exists && doc.data().deteted_at === undefined) {
console.log(doc.data())
return doc.data
}
}
)
it show me correct doc i want get. But when return , it undefined . Please help thanks you