【问题标题】:How to add timestamp to my document in cloud Firestore using Firebase Python Admin SDK?如何使用 Firebase Python Admin SDK 在 Cloud Firestore 中为我的文档添加时间戳?
【发布时间】:2019-07-30 08:40:27
【问题描述】:

我正在尝试将时间戳值以及其他详细信息添加到 Cloud Firestore 中的评论文档中。我想知道如何使用 Firebase Admin Python SDK 来做到这一点。 据我所知,要获取服务器时间戳,您可以在 JS SDK 中使用

admin.firestore().Field value.serverTimestamp()

是否有任何与此等效的 Python SDK?

【问题讨论】:

    标签: python firebase google-cloud-firestore firebase-admin


    【解决方案1】:

    来自documentation

    在更新时将字段设置为服务器上的当前时间 收到,使用 SERVER_TIMESTAMP 哨兵。

    >>> field_updates = {
    ...     'foo.now': firestore.SERVER_TIMESTAMP,
    ... }
    >>> document.update(field_updates)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 2019-05-16
      • 2019-11-26
      • 2019-12-02
      • 1970-01-01
      • 2018-06-10
      • 2018-05-10
      相关资源
      最近更新 更多