- Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
EDIT: Problem Found, see my next comment !
Collection.on_snapshot works only on top-level collections.
Calling on_snapshot on any sub-collection does nothing. It will be called once, where
first two arguments will be empty arrays, and last one will be correct timestamp, no matter what is actually inside of the collection. It will never be called again.
Someone already found this issue on the Stack Overflow:
https://stackoverflow.com/questions/54407320/firestore-listen-to-documents-in-a-subcollection
But no response given, nor any similiar issue opened.
Environment details
Fedora 29, Linux 4.20.14.-200.fc29.x86_64
Python 3.6.8 (virtualenv)
google-api-core==1.8.1 google-auth==1.6.3 google-cloud-core==0.29.1 google-cloud-firestore==0.31.0 google-cloud-storage==1.14.0 google-resumable-media==0.3.2 Steps to reproduce
- Create document with subcollection in Firestore
- Attach any listener on created collection
Code example
db = firestore.Client() def on_snapshot(snapshot, changes, ts): for doc in snapshot: print(doc) # This would work as expected db.collection("users").on_snapshot(on_snapshot) # These will do nothing db.collection("users/USER/values").on_snapshot(on_snapshot) db.collection("users", "USER", "values").on_snapshot(on_snapshot) db.collection("users").document("USER").collection("values").on_snapshot(on_snapshot)As pointed out, I am rewriting Node.js and similar code does indeed work in Node, but not in the Python version
Metadata
Metadata
Assignees
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.