A compound query that searches all Documents in a Collection works perfectly, as below:
var newData = admin.firestore().collection("MyProject").where('username', '==', 'myname');
In order to store more user generated data, I'm using "collection/doc/collection/doc" functionality where the docs are auto generated based on users' inputs.
Now to query data where anything is created in the last document, I want something like this:
var newData = admin.firestore().collection("MyProject/{docID}/subcollection")
.where('location', '==', 'location');
But this isn't working. Is there something else that I can try which would get me the results of matching content only?
(nor did the below)
var newData = admin.firestore().collection("MyProject".doc({docID}").collection("subcollection")
.where('location', '==', 'location');
Perhaps wildcards only work with Triggers and not queries? (https://firebase.google.com/docs/functions/firestore-events). I'm not sure as I couldn't any more documentation on web on this. Without this feature, I find collection/doc/collection/doc... style of storage quite limiting and useless.
One workaround I have thought of is fetching "all" the documents in MyCollection and run the query 'forEach' of those Documents. This would have higher complexity and more reads in Firestore, as there could be thousands of documents in MyProject.
Please share your wisdom on how to fetch data with least complexity. Thank you in advance!