Nhảy tới nội dung

CalendarDay

Lưu ý sau khi phiên bản KeystoneJS 5 chuyển sang chế độ duy trì để ra mắt phiên bản mới hơn. Chúng tôi đã dựa trên mã nguồn cũ này để phát triển một phiên bản khác với một số tính năng theo hướng microservices.

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

const { Text, Password, CalendarDay } = require("@ocop/fields");

ocop.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 OcopJS only.

Knex adapter

The Knex adapter uses the Knex date type:

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