When I query data from Firebase Firestore with documentId as field path, I get a different behaviour when running the script on webpage (javascript) and in Firebase Function (Node.js).
This javascript gives me perfect results:
firebase.firestore().collection('test')
.where(firebase.firestore.FieldPath.documentId(), '<=', 'ccc')
.get()
.then(snapshots => { /* results are here */ });
by contrast the same code in Firebase Function (Node.js):
admin.firestore().collection('test')
.where(admin.firestore.FieldPath.documentId(), '<=', 'ccc')
.get()
.then(snapshots => { /* ... */ });
gives me a error:
Error: { Error: a filter on __name__ must be a document resource name at ClientReadableStream._emitStatusIfDone (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:255:19) at ClientReadableStream._receiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:233:8) at /user_code/node_modules/firebase-admin/node_modules/grpc/src/client.js:705:12 code: 3, metadata: Metadata { _internal_repr: {} } }
I use my own document ids and I want to query by these ids. I know I can walk around this problem by querying by some document's inner field, but my question: what is the reason for this different behaviour? Thanks a lot.
My firebase version is 3.17.4
Edit: This bug was solved and does not appear in Firebase version 3.18.2.