I am working on a flutter project where I want a function that returns the Document ID. The only thing availabe is document field that is email or name.
What I want is:
if (email == email) { return documentID; }
2
new Promise((resolve, reject)=>{ db.collection('users').get().then((snapShot)=>{ const ids = []; snapShot.forEach((doc) => { const data = doc.data(); if (data.email || data.name) { ids.push(doc.id); } }); resolve(ids); }); });
As much as I don’t understand your request, I’ll make a guess.
I guess you want to get the id of this document when it matches the value you want.
String? id; await FirebaseFirestore.instance.collection('users').where('email', isEqualTo: 'email').get().then((value) => id = value.docs.first.id); print(id); //DocumentID
Click here to cancel reply.
2
Answers
As much as I don’t understand your request, I’ll make a guess.
I guess you want to get the id of this document when it matches the value you want.