Cerial
DecoratorsDatetime

@now

A computed Date field that evaluates to the current timestamp at query time — not stored in the database.

A computed field that evaluates to the current timestamp at query time. The value is not stored in the database — it is computed fresh on every read.

Syntax

model Post {
  id Record @id
  title String
  currentTime Date @now
}

Behavior

  • Date fields only@now can only be applied to fields of type Date.
  • Computed, not stored — Defined as COMPUTED time::now() in SurrealDB. The field does not exist in the stored record — it is evaluated each time the record is read.
  • Output-only — Because the value is computed by the database, it cannot be set in create or update operations. It is excluded from CreateInput, UpdateInput, and WhereInput types.
  • Always present in output — The field is always returned when the record is read (unless excluded by select).

Usage

const post = await client.db.Post.create({
  data: { title: 'Hello World' },
  // currentTime cannot be set — it's computed
});

// currentTime is always the current server time at read time
console.log(post.currentTime); // Date — e.g., 2025-01-15T10:30:00.000Z

Since the value is computed on every read, it reflects the time the query was executed, not the time the record was created.

@now fields are excluded from WhereInput — you cannot filter by a computed field. They are also excluded from OrderBy types.

Model Fields Only

@now is only allowed on model fields. It is not allowed on object fields or tuple elements.

SurrealDB requires COMPUTED fields to be top-level — they cannot be defined on embedded object sub-fields or tuple elements. Use @createdAt or @updatedAt for timestamp fields within objects.

Allowed On

ConstructAllowed
Model fields (Date)
Object fields
Tuple elements
Enum values
Literal fields

Mutual Exclusions

@now cannot be combined with any of these decorators on the same field:

  • @createdAt, @updatedAt — other timestamp decorators
  • @default, @defaultAlways — custom default strategies
  • @uuid, @uuid4, @uuid7 — UUID auto-generation decorators
  • @nullable — computed fields have no stored value to be null
  • @readonly — SurrealDB does not support READONLY on COMPUTED fields

When to Use @now vs @createdAt vs @updatedAt

DecoratorStoredSet on createUpdated on writeUse case
@nowNoN/A (computed)N/A (computed)Current server time at read
@createdAtYesYesNoRecord creation timestamp
@updatedAtYesYesYesLast modification timestamp
  • Use @createdAt for timestamps that record when something was created.
  • Use @updatedAt for timestamps that track the last modification.
  • Use @now when you need the current server time at the moment of reading, not a stored value.

On this page