Skip to content
KeystoneJS LogoKeystoneJS
👋🏻 Keystone 5 has officially moved to maintenance only. For the latest release of Keystone please visit the Keystone website.

CalendarDay

Stores an abstract "day" value; like a date but independant of any time zone. Useful for Birthdays and other all-day events always celebrated in the local time zone.

Usage

JS
const { Text, Password, CalendarDay } = require('@keystonejs/fields');

keystone.createList('User', {
  fields: {
    email: { type: Text },
    password: { type: Password },
    lastOnline: {
      type: CalendarDay,
      dateFrom: '2001-01-16',
      dateTo: '2020-05-20',
    },
  },
});

Config

OptionTypeDefaultDescription
dateFromStringundefinedThe starting point of the allowable date range.
dateToStringundefinedThe end point of the allowable date range.
isRequiredBooleanfalseDoes this field require a value?
isUniqueBooleanfalseAdds a unique index that allows only unique values to be stored

dateFrom

The CalendarDay field can enforce selected days to conform to a specific date range. dateFrom represents the start of a range and the earliest date that can be selected. dateFrom can be provided without a dateTo option. However, where a dateTo is provided, the dateFrom value must be equal to or earlier than the dateTo value.

dateTo

The CalendarDay field can enforce selected days to conform to a specific date range. datTo represents the end of a range and the latest date that can be selected. dateTo can be provided without a dateFrom option. However, where a dateFrom value is provided, the dateTo value must be equal to or after the dateFrom value.

GraphQL

CalendarDay fields use the String type in GraphQL.

All date values must be in the 10 character ISO8601 format:YYYY-MM-DD.

Filters

All filter fields expect values in the ISO8601 (YYYY-MM-DD) format.

Field nameTypeDescription
${path}StringMatching the value provided
${path}_notStringNot matching the value provided
${path}_in[String]Matching any of the values provided
${path}_not_in[String]Matching none of the values provided
${path}_ltStringBefore than the value provided
${path}_lteStringBefore or equal to the value provided
${path}_gtStringMore recent than the value provided
${path}_gteStringMore recent or equal to the value provided

Storage

Mongoose adapter

In Mongoose the field is added using the String schema type.

The isRequired config option is enforced by KeystoneJS only.

Knex adapter

The Knex adapter uses the Knex date type:

The isRequired config option is enforced by KeystoneJS and, if equal to true, the column is set as not nullable.

On this page

  • Usage
  • Config
  • GraphQL
  • Filters
  • Storage
  • Mongoose adapter
  • Knex adapter
Edit on GitHub