现在将服务器值设置为时间戳

时间:2019-03-25 13:06:03

标签: firebase google-cloud-firestore

我正在尝试使用firestore的其余api编写现在的时间戳。发送应用程序不会保留时间,因此要由服务器来存储值。

{
    "fields": {
        "Type": {
            "stringValue": "temperature"
            },
            "Timestamp": {
                "timestampValue": "2019-02-18T23:00:00Z"
            },
            "Value": {
                "integerValue": "17"
            }
    }
}

这些值已正确存储,但我希望能够将静态2019-02-18T23:00:00Z更改为现在的值。

这怎么办?

1 个答案:

答案 0 :(得分:1)

要在字段中写入服务器端时间戳,您需要为此使用FieldTransform。参见Firestore REST API add Timestamphttps://cloud.google.com/firestore/docs/reference/rest/v1/Write

相关问题