可以编写Firebase服务器时间戳而不做两个请求? [英] Can firebase server timestamps be written without making two requests?

查看:167
本文介绍了可以编写Firebase服务器时间戳而不做两个请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase REST API 描述了如何编写服务器值(当前仅支持时间戳),但似乎必须提交一个单独的请求才能执行此操作。有没有(或有计划)设置时间戳(如createdAt)在提交其他数据的同时?看起来像这样真的可以帮助减少流量和提高性能。

当然,这是可能的。这个文档当然有点不清楚,但是你需要做的只是在你的JSON负载中包含 {。sv:timestamp} 对象。下面是一个将它保存到 timestamp 的示例。



curl -X PUT - d'{something:something,timestamp:{。sv:timestamp}}'https://abc.firebaseio-demo.com/.json


The Firebase REST API describes how to write server values (currently only timestamps are supported) at a location, but it appears that one must submit a separate request in order to do this. Is there (or has there been planned) any way of setting timestamps (like createdAt) at the same time one submits other data? Seems like this would really help reduce traffic and improve performance.

解决方案

Sure, this is possible. The documentation is admittedly a little unclear, but all you need to do is include the {".sv": "timestamp"} object as part of your JSON payload. Here's an example that saves it to a key timestamp.

curl -X PUT -d '{"something":"something", "timestamp":{".sv": "timestamp"}}' https://abc.firebaseio-demo.com/.json

这篇关于可以编写Firebase服务器时间戳而不做两个请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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