Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can firebase server timestamps be written without making two requests?

Tags:

rest

firebase

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.

like image 223
cayblood Avatar asked Sep 30 '14 20:09

cayblood


People also ask

What is Firebase Timestamp?

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one.

What is the format of firestore timestamp?

Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.


1 Answers

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

like image 159
Ossama Avatar answered Oct 16 '22 07:10

Ossama