how store the firestore.SERVER_TIMESTAMP in array

Viewed 502

I would like to archive and then update an array which contains many firestore.SERVER_TIMESTAMP in firestore, but when I take this document and do

accesses.update({ u"mylist": [firestore.SERVER_TIMESTAMP]})

It throws

TypeError: ('Cannot convert to a Firestore Value', Sentinel: Value used to set a document field to the server timestamp., 'Invalid type', <class 'google.cloud.firestore_v1.transforms.Sentinel'>) 

So, it is possible to do this storing? How?

1 Answers

here is a similar question.

There shows a code like this:

import firebase_admin
from firebase_admin import firestore

# I have GOOGLE_APPLICATION_CREDENTIALS configured.
firebase_admin.initialize_app()
client = firestore.client()
result = client.collection('test').document('foo').set({
    'mytime':firestore.SERVER_TIMESTAMP
})
print(result)

This printed out:

update_time {
  seconds: 1523491166
  nanos: 932097000
}

And the value was stored in database as expected.

Related