Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Firestore - Unable to use FieldValue.serverTimestamp() #2429

Open
saturnism opened this issue Jun 12, 2020 · 1 comment
Open

Firestore - Unable to use FieldValue.serverTimestamp() #2429

saturnism opened this issue Jun 12, 2020 · 1 comment
Labels
firestore Firestore Native mode support P3

Comments

@saturnism
Copy link
Contributor

Is your feature request related to a problem? Please describe.
To set a timestamp in Firestore, it's a best practice to use the server-side timestamp as opposed to a timestamp generated by the client side. The server side timestamp is set using FieldValue.serverTimestamp();

Describe the solution you'd like
Unsure how to best support this use case, since we have strongly typed Timestamp field.

Describe alternatives you've considered
Make the field type FiledValue instead of Timestamp, but it's harder when retrieving.

@ttomsu ttomsu added the firestore Firestore Native mode support label Jun 24, 2020
@meltsufin meltsufin added the P3 label Jul 20, 2020
@elefeint
Copy link
Contributor

elefeint commented Jan 4, 2022

This was sort of done in GoogleCloudPlatform/spring-cloud-gcp#171 -- at least to retrieve the built-in server timestamp. The other side of this, creating a custom column that's set to server-generated timestamp, is not available through Spring Cloud GCP. We could likely implement it as an attribute on @UpdateTimestamp, something like @UpdateTimestamp(persisted=true).

Docs on setting an arbitrary field to be server timestamp: https://cloud.google.com/firestore/docs/manage-data/add-data#server_timestamp

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firestore Firestore Native mode support P3
Development

No branches or pull requests

4 participants