现在将服务器值设置为时间戳 [英] Set server value now as timestamp
问题描述
我正在尝试使用firestore的其余api编写现在的时间戳.发送应用程序不会保留时间,因此要由服务器来存储值.
{字段":{类型": {"stringValue":温度"},时间戳记":{"timestampValue":"2019-02-18T23:00:00Z"},价值": {"integerValue":"17"}}}
这些值已正确存储,但我希望能够将静态2019-02-18T23:00:00Z更改为现在的值.
这怎么办?
要在字段中写入服务器端时间戳,您需要使用 Firestore REST API添加时间戳和 https://cloud.google.com/firestore/docs/reference/rest/v1/写 >
I'm trying to write the now timestamp using the rest api of firestore. The sending application doesn't keep the time so its up to the server to store the value.
{
"fields": {
"Type": {
"stringValue": "temperature"
},
"Timestamp": {
"timestampValue": "2019-02-18T23:00:00Z"
},
"Value": {
"integerValue": "17"
}
}
}
The values get stored properly but I want to be able to change the static 2019-02-18T23:00:00Z to the now value.
How can this be done?
To write the server-side timestamp in a field, you need to use a FieldTransform
for that. See Firestore REST API add Timestamp and https://cloud.google.com/firestore/docs/reference/rest/v1/Write
这篇关于现在将服务器值设置为时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!