Skip to content

Support for callable server timestamp #59

Description

@fwal

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions