Skip to content

Instantly share code, notes, and snippets.

@shakirullahi
Created December 23, 2013 09:22
Show Gist options
  • Save shakirullahi/8093974 to your computer and use it in GitHub Desktop.
Save shakirullahi/8093974 to your computer and use it in GitHub Desktop.
Setting priority while pushing in firebase //credit:kato
var ref = new Firebase('https://<example>.firebaseio.com/rewards').push();
ref.setWithPriority({
name: 'apple',
otherKey: 'somevalue',
...
}, 'apple', function(err) {
if( error ) { console.error(err); }
else {
fetchValue();
}
});
function fetchValue() {
// wait for the set to complete before fetching data
new Firebase('https://<example>.firebaseio.com/rewards')
.startAt('apple')
.endAt('apple')
.once('value', function(snap) {
console.log('found:', snap.val()); // logs: "found null"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment