Reputation: 1868
Creating a node app in Firebase, and having a lot of trouble "setting" values. I have a sneaking suspicion this has to do with permissions or something (I haven't set any read/write permissions of my own), but not sure. Simplified code below:
var Firebase = require("firebase");
var Scope = new Firebase('https://my-firebase.firebaseio.com/');
Scope.child("users").child(queue.uid).on('value', function(user) {
console.log(user.val()); // Works fine
user.set({id: 123}); // Fails, "Object has no method 'set'"
});
Any ideas would be much appreciated.
Upvotes: 0
Views: 3830
Reputation: 40582
The user
variable being passed into the value
callback is actually a snapshot--not a Firebase ref. So there is no set method.
However, the ref is available on the snapshot by calling .ref():
Scope.child("users").child(queue.uid).on('value', function(user) {
console.log(user.val()); // Works fine
user.ref().set({id: 123}); // Yay!
});
Upvotes: 5