Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wildcards in firestore cloud functions?

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.

like image 942
Raul Garcia Avatar asked Dec 17 '22 19:12

Raul Garcia


1 Answers

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.

like image 135
Doug Stevenson Avatar answered Jan 06 '23 14:01

Doug Stevenson