New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.where(admin.firestore.FieldPath.documentId(), 'in', ['id1', 'id2']) fails: '... FieldPath.documentId() must be a string or a DocumentReference' #990
Comments
Happening to me too, if not an issue, please provide information ou how to make a query based on a list of document Ids. There simply is no documentation examples on that. My current workaround is to use firestore's getAll: refs = arr.map(doc => db.collection('media').doc(doc));
const m = await db.getAll(...refs); |
I will get this fixed today. |
Thanks! |
Looks like this issue persists when running with Firebase local emulator. Is there a way to verify the package version used in the emulator? @schmidt-sebastian |
You can always use |
My |
After looking at the tests, I tried to use This works: import { FieldPath, Firestore } from '@google-cloud/firestore'
const firestore = new Firestore()
const menus = await firestore
.collection('menus')
.where(FieldPath.documentId(), 'in', ['cUKi4Kj42LOcLsqBZOBhM'])
.get() This doesn't: import admin from 'firebase-admin'
const menus = await admin
.firestore()
.collection('menus')
.where(admin.firestore.FieldPath.documentId(), 'in', [
'cUKi4Kj42LOcLsqBZOBhM',
])
.get()
}
start() It seems that |
This works for me const firebase = require("@firebase/testing")
const admin = firebase.initializeAdminApp({
projectId: "my-test-project"
})
// ... //
// it as to be firebase from @firebase/testing
admin.firestore()
.collection("users")
.where(firebase.firestore.FieldPath.documentId(), "in", userIds)
.get() |
This works for me const admin = require("firebase-admin");
const arr = ["id1", "id2"];
const refArr = arr.map(id => admin.firestore().collection("media").doc(id));
const m = await admin
.firestore()
.collection("media")
.where(admin.firestore.FieldPath.documentId(), "in", refArr)
.get(); |
Somehow the query works without const query = admin.firestore()
.collection('users')
.where(firebase.firestore.FieldPath.documentId(), 'in', userIds)
.orderBy('firstName');
const results = await transaction.get(query); |
@5amfung The query you are issuing should be rejected by the backend ("inequality filter property and first sort order must be the same: key and firstName"). If you are using an "in" filter, you also need to use this field as the first orderBy constraint. You can then add additional orderBy constraints afterwards (e.g. |
Environment details
@google-cloud/firestore
version: 3.7.2firebase-admin
version: 8.10.0Steps to reproduce
Expected: able to query a list of document IDs in a single collection.
Actual:
Does anyone know a workaround? Thanks! (edited several times for clarity)
The text was updated successfully, but these errors were encountered: