So I have a document in this form:
Field:
NestedField: Value
How can I use the where() method in Flutter to fetch all documents that satisfy a condition on NestedField? I.e:
Firestore.collection("forms").where("Field.NestedField",isEqualsTo: "Op1").getDocuments(). // This returns null
Alright, so this was caused by another error with no relation to Firestore directly. The Field.NesterForm approach works and it returns the data. Since Firestore uses JSON then it's the correct way to access nested fields this way. The code I was testing with was:
List<DocumentSnapshot> docs;
await Firestore.instance.collection('form')
..where("FirstForm.Operator",isEqualTo: _filter.text)
.getDocuments().then((query) {
docs = query.documents;
});
print("DOCS: $docs");
The .. before the where() that I didn't see at first caused the awaitto not actually wait for the return so the print of my docs variable always returned null. Once I removed one dot, it works fine now and the equals is working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With