Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

(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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...