Firestore + App Engine for realtime updates possible? - firebase

This documentation link for App Engine outlines an example where app engine listens to a RealTime Database reference.
I was wondering if
This can be done equivalently with Firestore using .onSnapshot
Whether I can specify wildcards in the reference as I do with cloud function triggers

Yes
No
There are no wildcard listeners with the Firestore SDK. Cloud Functions is responding to events generated by Firestore, which is very different than how a listener in the SDK works.

Related

Can I create triggers with Admin SDK in my own backend?

I am new to Firebase and learning it. With Cloud Functions you can create trigger listeners to events that happen in Firestore (firestore events) or Authentication (auth events). Can I create listeners similarly with the Admin SDK of Firestore or Authentication in my own nodejs environment?
No, Cloud Functions triggers only work on the Cloud Functions backend, as they depend heavily on Google Cloud infrastructure to work efficiently. There is no exact equivalent for other environments. You can certainly use the provided nodejs Firestore SDK to set up a document or query listener, just like web and mobile clients, but it won't behave like a Cloud Functions trigger.

Is there any way to check how many read/write on Cloud Firestore via sdk?

Is there any way to check how many read/write on my app on Cloud Firestore?
There currently is no API to get the number of reads/writes from Cloud Firestore. Neither the client-side SDKs nor the server-side Admin SDKs expose this functionality.
The closest I can think of is something based on StackDriver monitoring that you can set up for Firestore. Based on that you can then wrap the StackDriver monitoring API in a custom end point (either in Cloud Functions or elsewhere).

How to switch from Datastore to Firestore in existing project?

I have an existing Google Cloud project which uses Datastore. I'm excited by Firestore and would like to switch. According to https://www.youtube.com/watch?v=SYG-BgXoJFQ it is recommended to create a new project.
Is it possible to just nuke Datastore somehow (I don't care about the data) and start from scratch with Firestore?
If not, what are the implications of creating a new project?
If there is no data written to Cloud datastore, it's possible to convert from datastore to firestore with the following steps. I tried on 2 projects and each project took 3 minutes. The user should be the project owner to attempt:
Disable Cloud datastore API
Disable Cloud Firestore API
gcloud firestore databases create --region=us-central --project $PROJECT_ID
I have another project that has little datastore entities. I deleted them and executed the steps, but received the following error. While disabling datastore API, I read Disable Cloud Datastore API? If any resources were created by Cloud Datastore API, they may be deleted soon after Cloud Datastore API is disabled. All code that uses this project's credentials to call Cloud Datastore API will fail.
ERROR: (gcloud.firestore.databases.create) Error Response: [9] The
"database_type" field cannot be modified for this application. Note:
If data has already been written for this application, then the
"database_type" may not be modified.
The solution is to contact Google cloud support to convert from Datastore to Firestore. You need to make sure no entities exist and nothing is creating any entities.
In the case where no Datastore entities have been written, the operation should succeed:
Success! Selected Google Cloud Firestore Native database for $PROJECT_ID
It is not possible to switch from Datastore to Firestore within the same project as yet, but you may operate Firestore in Datastore mode. By creating a Cloud Firestore database in Datastore mode, you can access Cloud Firestore's improved storage layer while keeping Cloud Datastore system behavior. You may find more information of relevance by reading the "Automatic Upgrade to Cloud Firestore" documentation page.

How do I use Cloud DataStore or Cloud SQL from Cloud Functions for Firebase?

I'm building a Firebase app, and plan to use the real-time database when I need real-time updates. However, most of the application data is more traditional.
Now that Functions is a thing, how do I also leverage either DataStore or CloudSQL? Can anyone point me to specific documentation or examples how to read/write with either of those services from a function?
Neither Cloud Datastore nor Cloud SQL support Cloud Functions yet, which means you aren't yet able to trigger Cloud Functions based on their events the way you can with the Firebase Realtime Database.
Fortunately, once a Cloud Function has been triggered (for example via HTTP), you can still read and write from Datastore and SQL as you would from any other Node.js code. Here is documentation for Cloud Datastore, and here it is for Cloud SQL.
Finally, if you're adventurous and might like to provide early feedback on upcoming integrations like Datastore, fill out this form!

Firebase Cloud Function trigger

As I know currently Cloud Functions doesn't support triggering functions from Firebase.
For now I'm planing to use an basic Engine instance to trigger the functions based on the queue.
Is this the right way to go? or should I trigger the cloud function directly from the clients device after the data is inserted in the db?
thank you
Cloud Functions for Firebase was just launched today! You can use the SDK to trigger cloud functions from your Firebase database, storage bucket, authentication, and analytics events. https://firebase.google.com/docs/functions/

Resources