Very strange behaviour I am experiencing with firestore.
Below dart code does not return the value
await Firestore.instance.collection('users')
.where("phoneNumber", isEqualTo: phoneNumber)
.getDocuments();
The javascript code from web returns the value
db.collection('users').where('phoneNumber', '==', 'xxxxxxxxxx').get().then((result) => {
console.log( result.docs.length )
}).catch((err) => {
console.log(err)
});
But I can clearly see the phone number does exist in the colection. I just don't know if this is because of pending writes or cache. Where can I disable it if that is the case?
edit the code for phNumber
Future<User> getPhoneUser(String phoneNumber) async {
if (phoneNumber == 'xxxxxxxxxx') {
print('yes the phone number is same');
}
try {
QuerySnapshot qsnap = await usersRef
.where("phoneNumber", isEqualTo: phoneNumber)
.getDocuments();
int length = qsnap.documents.length;
if (length > 0) {
DocumentSnapshot doc = qsnap.documents[0];
doc.data['id'] = doc.documentID;
doc.data['createdAt'] = doc.data['createdAt'].toDate().toString();
doc.data['updatedAt'] = doc.data['updatedAt'].toDate().toString();
User user = User.fromJson(doc.data);
return user;
} else {
return null;
}
} catch (error) {
return null;
}
}