ServerTimestamp exists as a schema class and the admin converter already maps it to FieldValue.serverTimestamp(), but it is only reachable through Model.DateTimeInsert / Model.DateTimeUpdate. There is no user-callable serverTimestamp() sentinel for writing a server timestamp to an arbitrary timestamp field.
Motivation
serverTimestamp is by far the most-used field sentinel in real-world Firestore code (e.g. lastSeenAt, processedAt, domain-specific timestamps that aren't the model's insert/update fields). Since these fields can't use the auto-managed DateTimeInsert/DateTimeUpdate helpers, every write today bypasses the library with a raw FieldValue.serverTimestamp().
Suggested shape
- A
serverTimestamp() constructor exported alongside the existing field sentinels (arrayUnion, arrayRemove, delete), producing the existing ServerTimestamp instance
- A model helper in the style of
WithArrayFields that adds the ServerTimestampInstance to a timestamp field's insert/update variants, so it flows through Repository.add/Repository.update with full typing
The converter side is already done — this is mostly about exposing the sentinel and typing it into the model variants.
ServerTimestampexists as a schema class and the admin converter already maps it toFieldValue.serverTimestamp(), but it is only reachable throughModel.DateTimeInsert/Model.DateTimeUpdate. There is no user-callableserverTimestamp()sentinel for writing a server timestamp to an arbitrary timestamp field.Motivation
serverTimestampis by far the most-used field sentinel in real-world Firestore code (e.g.lastSeenAt,processedAt, domain-specific timestamps that aren't the model's insert/update fields). Since these fields can't use the auto-managedDateTimeInsert/DateTimeUpdatehelpers, every write today bypasses the library with a rawFieldValue.serverTimestamp().Suggested shape
serverTimestamp()constructor exported alongside the existing field sentinels (arrayUnion,arrayRemove,delete), producing the existingServerTimestampinstanceWithArrayFieldsthat adds theServerTimestampInstanceto a timestamp field'sinsert/updatevariants, so it flows throughRepository.add/Repository.updatewith full typingThe converter side is already done — this is mostly about exposing the sentinel and typing it into the model variants.