Search code examples
firebasegoogle-cloud-firestoretimestampmetadata

Is there a Firestore Timestamp in metadata for Document Creation?


I am wondering if Cloud Firestore timestamps each document on creation in its metadata, and if so, is that metadata available?

I know I can create my own timestamps inside a document for arbitrary reasons, but I'm only interested in when the document itself was created.

Thanks in advance


Solution

  • Edit Apr 27'th 2023:

    In google.firestore.v1 the document contains now create_time and update_time, both being of type Timestamp.


    Edit Jan 21'th 2022:

    In Android, you can call DocumentSnapshot.getMetadata() method or QuerySnapshot.getMetadata(), which both return an object of type SnapshotMetadata. By the time I'm editing this answer, in this class there is no method that returns a timestamp. There is only a hasPendingWrites() and isFromCache().


    I am wondering if Firestore timestamps each document on creation in its metadata

    No, it does not.

    I know I can create my own timestamps inside a document

    That's the solution you should go ahead with. Add the timestamp of the creation as a field within every document.