Pranay Ankit
Pranay Ankit

Reputation: 227

How to add timestamp to my document in cloud Firestore using Firebase Python Admin SDK?

I'm trying to add a timestamp value, along with other details to a comment document in Cloud Firestore. I would like to know how can I do it using Firebase Admin Python SDK. As far as I know to get server time stamp, in JS SDK you use

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

Is there any Python SDK equivalent of this?

Upvotes: 1

Views: 1129

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83153

From the documentation:

To set a field to the current time on the server when the update is received, use the SERVER_TIMESTAMP sentinel.

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

Upvotes: 3

Related Questions