I’m trying to do a Document query on Firestore inside a subcollection but it seems that I’m doing something wrong.
For instance, if I want to do a query to find a document having myField to “searchField” inside the MY_SUBCOLLECTION subcollection, I’m doing this:
You should in theory be able to use a full JSON payload to achieve this - check out this post from my teammate @MutedJam :
I was trying to look into how to get sub-collections for you for a bit - but I’m afraid I’m honestly fairly stuck I thought that this would be the way to go: StructuredQuery | Firebase
But even with that selector, I was only able to get the main collection’s data. Perhaps someone with a better understanding of Firestore can jump in here for you - I tried to also pull in @MutedJam on this one, and sadly he isn’t too sure either.
My best advice as well would be to disable the “simplify” option on the Firebase node as you play around, too. If you’re trying to run these queries, n8n logic may not output the data in the way you want.
For those who are interested, I tried an alternative by making an http request directly.
It allows to search documents for a subcollection which have a specific field (here myField). However, I still didn’t managed to apply a filter on this document list to only receive the one which have myField to a specific value.
At least it allows you to search within a subcollection, but it still doesn’t allow you to obtain a document with a specific field value.
Here is the request: https://firestore.googleapis.com/v1/projects/[YOUR_PROJECT_ID]/databases/(default)/documents/MY_COLLECTION/byHhQXxmeslQTgvJYs5E/MY_SUBCOLLECTION?orderBy=myField
(Don’t forget to replace [YOUR_PROJECT_ID] with your Firebase project id)