Push to Firebase via REST API with Priority

firebase

Solution

Yes! To post data with a priority, you can use:

var myObj = JSON.stringify({name: 'My Name', address: 'My Address', '.priority': 123});
$.post('http://demo.firebase.com/demo/testing.json', myObj);

If you want to post a raw value (e.g. "hello") with a priority, use:

var myObj = JSON.stringify({'.value': 'hello', '.priority': 123});
$.post('http://demo.firebase.com/demo/testing.json', myObj);

Problem

Is it possible to use the REST API to push an event to a list (via an HTTP POST) and also specify the priority of the item that is being pushed? Perhaps as a field in the JSON I am posting somehow? Something like this (semi-pseudo-code): ``` var myObj = {name: 'My Name', address: 'My Address'}; myObj['priority'] = 123; $.post('http://demo.firebase.com/demo/testing.json', myObj); ``` I can do it the following way with the native Javascript library but this does not use the REST API: ``` var fb = new Firebase('http://demo.firebase.com/demo/testing'); var foo = fb.push({name: 'My Name', address: 'My Address'}); foo.setPriority(1); ```

Original source