通过具有优先级的REST API推送到Firebase [英] Push to Firebase via REST API with Priority

查看:130
本文介绍了通过具有优先级的REST API推送到Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用REST API将事件推送到列表(通过HTTP POST)并指定正在推送的项目的优先级?也许作为一个字段在JSON我张贴莫名其妙?



类似这样(semi-pseudo-code):

<我的名字',地址:'我的地址'};
myObj ['priority'] = 123;

$ .post('http://demo.firebase.com/demo/testing.json',myObj);

我可以通过以下方式使用原生Javascript库进行操作,但不使用REST API:


$ b

  var fb = new Firebase('http://demo.firebase.com/demo/测试'); 
var foo = fb.push({name:'My Name',address:'My Address'});
foo.setPriority(1);


解决方案

是的!要发布具有优先级的数据,您可以使用:

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

如果您想以优先级发布原始值(例如hello),请使用: / p>

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


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);

解决方案

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);

这篇关于通过具有优先级的REST API推送到Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆