Skip to content
KeystoneJS LogoKeystoneJS (α)

CalendarDay

Usage

keystone.createList('User', {
  fields: {
    email: { type: Text },
    password: { type: Password },
    lastOnline: {
      type: CalendarDay,
      format: 'Do MMMM YYYY',
      yearRangeFrom: 1901,
      yearRangeTo: 2018,
      yearPickerType: 'auto',
    },
  },
});

Config

OptionTypeDefaultDescription
formatStringYYYY-MM-DDDefines the format of string that the component generates
yearRangeFromStringThe current year - 100Defines the starting point of the year range, eg 1918
yearRangeToStringThe current yearDefines the ending point of the range in the yearSelect field , e.g 2018
yearPickerTypeStringautoDefines the input type for the year selector
isRequiredBooleanfalseDoes this field require a value?
isUniqueBooleanfalseAdds a unique index that allows only unique values to be stored

format

Defines the format of string that the component generates. For example, Do MMMM YYYY.

yearRangeFrom

The CalendarDay component includes an input that allows the user to change the current year from a range of options. This prop allows the user to set the beginning of that range.

The default value for this field is 100 years before the current year.

yearRangeTo

The CalendarDay component includes an input that allows the user to change the current year from a range of options. This prop allows the user to set the end of that range.

The default value for this field is the current year.

yearPickerType

The CalendarDay component includes an input that allows the user to change the current year from a range of options. This prop allows the user to change the type of that input.

OptionDescription
inputGenerates an input that allows the user to type in a value
selectGenerates a drop-down menu that allows the user to select a value from a list
autoWill generate a select if the range is 50 or less, otherwise will generate an input

GraphQL

CalendarDay fields use the String type in GraphQL. They produce and values according to their configured format but always expect values in ISO8601 (YYYY-MM-DD) format.

Input Fields

Field nameTypeDescription
${path}StringThe value to be stored, in ISO8601 (YYYY-MM-DD) format

Output Fields

Field nameTypeDescription
${path}BooleanThe stored value in the configured format

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 Adaptor

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

The isRequired config option is enforces by Keystone only.

Knex Adaptor

The Knex adaptor uses the Knex date type:

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

Have you found a mistake, something that is missing, or could be improved on this page? Please edit the Markdown file on GitHub and submit a PR with your changes.

Edit Page