I have a likes value in the database and i want to change the value STATE when likes is more than 10. Here is my database structure
My firebase function
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.newPost = functions.database
.ref('/QUESTIONS/SPANISH/{postID}'/"LIKES")
.onWrite(function(event) {
const likes=event.data.value;
const id=event.params.postID;
if(likes>10){
return event.data.ref.parent.child('STATE').set("ACEPTED");
}
return false;
});
The function is deployed correctly and all but when i increment the likes nothing happens, what i am doing wrong?
via Tinco De Simone
No comments:
Post a Comment