I'm trying to listen to document changes with the following code: (Flutter)
Firestore.instance
.collection('myCollection')
.where("owners.${myUserID}", isEqualTo: true)
.orderBy("lastRef", descending: true)
.snapshots()
.listen((data) {
print("listening");
data.documentChanges.forEach((change) {
setState(() {
myList = data.documents;
});
});
});
This code only works once, it adds all the right documents to the list, but when a document is updated, it doens't do anything...
I tried this code (without the where query)
Firestore.instance
.collection('myCollection')
.orderBy("lastRef", descending: true)
.snapshots()
.listen((data) {
print("listening");
data.documentChanges.forEach((change) {
setState(() {
myList = data.documents;
});
});
});
Works perfectly, even when a document is updated
I thought I'd had to make an index, but i didn't see any message in the console. Tried creating one manually.
Indexed fields: owners (array), lastRef (descending)
What am I doing wrong?
Thanks in advance!
myUserID? (for example, by printing it right before you run the query), 2) a screenshot of a document that should be returned by the query? - Frank van Puffelen