I'm trying to use a wildcard in a cloud function with firestore like this:
exports.function_name= functions.https.onRequest((req, res) => {
return admin.firestore().collection('users/messages/{messageCollectionId}')
but it does not work. It works if I use an actual id, instead of the wildcard. Any help will be much appreciated.
There are no wildcards in Firestore paths to documents. You have to identify collections and documents by their IDs. If you need to find some documents based on some property, you'll need to do a query using some field value as a filter.
You might be confused by wildcards in Cloud Functions trigger paths. When you define a Firestore trigger function, you can use a wildcard to determine which documents would trigger that function, but you can't use them with the client SDKs to locate documents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With