ChatiumFor developersPlaygroundPricing
Sign in

Heap.DateTime

Declares a field of type Date.

This is a non-standard type in the JSON schema. It is stored in the database as a string returned by Date.toISOString(), and at runtime, it is represented by an instance of the standard JavaScript class Date.

Usage / Signature

import { Heap } from '@app/heap'
Heap.DateTime(options)

Arguments

  • <b id="options">options</b>: {default}
    An object with additional optional parameters for the field.

    • <b id="default">default</b>: string|'now'
      The default value for this field. For more information on how default values work, see Guide / Heap / Default Values.

      Possible formats for the default value

      • <span id="string">string</span>
        Any string representation of date+time that can be accepted by the JavaScript Date constructor.

      • <span id="now">'now'</span>
        The moment of record creation. This option is only valid at the time of writing and does not work when reading to substitute a non-existent value.

Return Value

A JSON schema for a string field with validation format: date-time.

Examples

Date/time field with a default value of "current time of record creation"

const customers = Heap.Table('customers', {
  lastActionAt: Heap.DateTime({ default: 'now' }),
})