我正在尝试使用 firestore 的其余 api 写入现在的时间戳。发送应用程序不保留时间,因此由服务器来存储该值。
{
"fields": {
"Type": {
"stringValue": "temperature"
},
"Timestamp": {
"timestampValue": "2019-02-18T23:00:00Z"
},
"Value": {
"integerValue": "17"
}
}
}
这些值已正确存储,但我希望能够将静态 2019-02-18T23:00:00Z 更改为当前值。
如何做到这一点?
最佳答案
要将服务器端时间戳写入字段中,您需要使用 FieldTransform
为了那个原因。请参阅Firestore REST API add Timestamp和 https://cloud.google.com/firestore/docs/reference/rest/v1/Write
关于firebase - 现在将服务器值设置为时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55338493/