Home > Mobile >  Firebase Realtime Database Triggers on Cloud Run or Kubernetes, Not Cloud Functions
Firebase Realtime Database Triggers on Cloud Run or Kubernetes, Not Cloud Functions

Time:09-25

Based on Firebase documentation, one can create a cloud function to trigger when documents are added/updated/deleted on Firebase database through:

functions.database.ref('/messages/{pushId}/original').onUpdate();

However, using the Node.js admin SDK, when I call the following:

admin.database().ref("/messages/{pushId}/original").onUpdate();

It returns the error:

TypeError: admin.database(...).ref(...).onUpdate is not a function

What else we should do to get access to Firebase Realtime Database Triggers on Cloud Run or Kubernetes?

CodePudding user response:

firebaser here

The onUpdate method only exists in the firebase-functions SDK and in the Cloud Functions equivalent on GCP. It does not exist in the Firebase Admin SDK, which is why you get an error when you try to use it there.

While it may be possible to receive Realtime Database events on Cloud Run (I haven't tried this myself), you will have to follow the process outlined for Eventarc on Cloud Run and then wire up the Realtime Database events as documented there.

Update: as a team mate pointed out, the Realtime Database triggers you can receive through Eventarc today are for administrative events, like creation and deletion of database instances. Triggers for data-level events are in the works, but not available yet (nor any timelines on when they will be).

  • Related