"how to update a value in firebase realtime database using cloud functions for firebase" Code Answer

4

you are trying to call update() on a deltasnapshot object. there is no such method on that type of object.

var eventsnapshot = event.data;
eventsnapshot.update({
    "isverified": true
});

event.data is a deltasnapshot. if you want to change the data at the location of the change represented by this object. use its ref property to get a hold of a reference object:

var ref = event.data.ref;
ref.update({
    "isverified": true
});

also, if you are reading or writing the database in a function, you should always return a promise that indicates when the change is complete:

return ref.update({
    "isverified": true
});

i would recommend taking frank's advice from the comments and study the existing sample code and documentation to better understand how cloud functions works.

By CursedMun on May 12 2022

Answers related to “how to update a value in firebase realtime database using cloud functions for firebase”

Only authorized users can answer the Search term. Please sign in first, or register a free account.