Johntopia
Johntopia

Reputation: 353

(Flutter) How to retrieve document from Firestore using Cloud Functions for Firebase

I am trying to write a Cloud Function in Node.js.

The function requires to return a Cloud Firestore document data as a json form.

I have read the document, where I could find Cloud Functions can be triggered on Cloud Firestore events such as onCreate and onDelete.

However, beyond these event cases, where the documents are not updated nor deleted, I would like to know if this could be done using functions.firestore object.

Is it possible? Or should I just use the REST API for Cloud Firestore and create sth like functions.https.onRequest. If your choice is the latter how should this be implemented in Flutter?

Upvotes: 0

Views: 605

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598817

It sounds like you want to use Cloud Functions to create an API that your app can call to get back some data from Firestore. This is indeed possible, and in fact quite common.

In this case you'll implement either a so-called HTTP function or a Callable Cloud Function that performs the necessary interaction with Firestore through the Node.js Admin SDK.

Upvotes: 2

Related Questions