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
collectionGroup() and query with FieldPath #587
Comments
I found a few problems with this issue:
|
Ideally this should be reported at https://github.com/googleapis/nodejs-firestore Assigning to @schmidt-sebastian to review and triage as necessary. |
@Cdik Thanks for reporting this! From the error message, it appears that you are passing a single string value ( Collection group queries with document filters require full document paths and must include the collection for the document you are querying. Notice that for Can you double-check that "myDocumentId" points to a document? Alternatively, you can also pass a DocumentReference instead of a string. See this test case for an example: https://github.com/googleapis/nodejs-firestore/blob/fc6f8392fd07ee93f5321be6808a78f7cdde3b2b/dev/system-test/firestore.ts#L1398 |
I have a similar question. I have documents organized into
I see that I can add
Is there a way to do this using the |
Better late than never 😄 but it looks like @jlara310 has the same issue. I get what you mean by not knowing the document path but it will make no sense to pass the full path as it is what I am looking for.
where And yes, "myDocumentId" points to a document. And again, how could I pass a DocumentReference if, it is what I'm looking for. Thanks in advance. Hope it helps. Cheers |
You should be able to pass a DocumentReference, and the SDK will do the right thing (or attempt to). |
@schmidt-sebastian I have exactly the same issue. Using the full path of the document completely defeats the purpose of collection group queries. In my case I use the user ID for document IDs on different levels. In my firestore I have documents placed at
gives an error "When querying a collection group and ordering by FieldPath.documentId(), the corresponding value must result in a valid document path, but 'XF0c0r4iTYQjJHA0xhUgaZNvffzB' is not because it contains an odd number of segments." Is this query simply not possible in Firestore and I have to duplicate the user ID in the document that I'm storing? |
Yea this is garbage. The point of collection group queries is the ability to do them over several parent documents. Having to specify a single parent document through the full path completely unmakes the purpose, a plain collection query can do this. |
I wonder if |
Hi all,
Sorry if this issue shouldn't be posted here. I can't find the right place to post it.
is there a good reason why I can't query a collectionGroup() with FieldPath.documentId()??
It's working fine if a query on a specific collection but when I try querying from collectionGroup I get
and of course if I try adding a '/' at the end of the FieldPath, I get
Here are the tested codes:
Doesn't work -->
Works -->
Does anyone knows how I can trick that? Or if it could be fixed in the next release? Or even if there's a good reason why it is not possible?
Thanks
The text was updated successfully, but these errors were encountered: