Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Datetime<Format>

Stores a date and the time. Accepts only timestamps - number or ms since Epoch. Can be configured and filtered by in the same way as other IntStorage-based fields.

Type parameters

  • Format

Hierarchy

  • IntStorage<number | string, number | string>
    • Datetime

Index

Constructors

constructor

  • new Datetime(app: App, collection: Collection, name: string, required: boolean, display_hints: any): Datetime
  • Creates a new instance of a field

    Parameters

    • app: App
    • collection: Collection
    • name: string
    • required: boolean
    • display_hints: any

    Returns Datetime

Properties

collection

collection: Collection

The collection this field is attached to

display_hints

display_hints: any

The display hints specified for this field

handles_large_data

handles_large_data: boolean = false

Whether or not the field handles large data

todo:

see if there's any viability in storing this

Optional max

max: undefined | number

tha max allowed value

Optional min

min: undefined | number

the min allowed value

name

name: string

the name of the field

required

required: boolean

Whether or not this field should always have a value. Creating a resource with a value missing for a required field will throw an error

Methods

decode

  • decode(_: Context, db_value: number | null, __: number, format?: undefined | "human_readable"): Promise<null | string | number>
  • Parameters

    • _: Context
    • db_value: number | null
    • __: number
    • Optional format: undefined | "human_readable"

    Returns Promise<null | string | number>

encode

  • encode(_: Context, value_in_code: number | string | null): Promise<null | number>
  • Parameters

    • _: Context
    • value_in_code: number | string | null

    Returns Promise<null | number>

filterToQuery

fullTextSearchEnabled

  • fullTextSearchEnabled(): Promise<boolean>
  • Whether or not the db should create a fulltext index on this field

    Returns Promise<boolean>

getAggregationStages

  • getAggregationStages(context: Context, query_params: { filter?: undefined | {} }): Promise<QueryStage[]>
  • Creates parts of a Mongo Pipieline that will be used to filter the items when listing items of a collection

    Parameters

    • context: Context
    • query_params: { filter?: undefined | {} }
      • Optional filter?: undefined | {}

    Returns Promise<QueryStage[]>

getAttachmentLoader

  • getAttachmentLoader(context: Context, omit_it: Boolean, attachment_params: ConstructorParameters<typeof ReferenceToCollection>[2]): AttachmentLoader | null
  • If the field supports attachments, it should return a properly configured AttachmentLoader. Not necessary for most basic fields.

    Parameters

    • context: Context
    • omit_it: Boolean
    • attachment_params: ConstructorParameters<typeof ReferenceToCollection>[2]

    Returns AttachmentLoader | null

getDefaultValue

getSpecification

  • getSpecification(): { display_hints: any; name: string; type: string }
  • Return a summary of this field

    Returns { display_hints: any; name: string; type: string }

    • display_hints: any
    • name: string
    • type: string

getTypeName

  • getTypeName(): string

getValuePath

  • getValuePath(): Promise<string>
  • Value path is where inside a single record should the DB look for the field's value when filtering resources. Some fields use complex objects for storage and overwrite this method, and thanks to that they don't have to reimplement Field.getAggregationStages

    Returns Promise<string>

hasDefaultValue

  • hasDefaultValue(): boolean
  • Whether or not a field has a default value - that is, a value given to the field if no value is provided

    Returns boolean

hasIndex

  • hasIndex(): boolean | "text" | {}
  • Whether or not this field should have a dedicated index in the database

    Returns boolean | "text" | {}

init

  • init(_: App): Promise<void>
  • Runs when the app is being started. Hooks can be set up within this function

    Parameters

    Returns Promise<void>

isOldValueSensitive

  • Whether or not any of the methods of the field depend on the previous value of the field

    Parameters

    Returns boolean

isProperValue

  • isProperValue(_: Context, value: number | string): Promise<{ reason?: undefined | string; valid: boolean }>
  • Parameters

    • _: Context
    • value: number | string

    Returns Promise<{ reason?: undefined | string; valid: boolean }>

setParams

Static fromDefinition

  • fromDefinition<T>(app: App, collection: Collection, definition: { display_hints?: any; name: string; params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]; required?: undefined | false | true; type: T }): Field<any, any, any>
  • Create a new instance of Field based on the definition. **It's recommended to use FieldDefinitionHelper instead

    Type parameters

    Parameters

    • app: App
    • collection: Collection
    • definition: { display_hints?: any; name: string; params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]; required?: undefined | false | true; type: T }
      • Optional display_hints?: any
      • name: string
      • Optional params?: Parameters<InstanceType<FieldClass>["setParams"]>[0]
      • Optional required?: undefined | false | true
      • type: T

    Returns Field<any, any, any>

Static invalid

Static valid

Generated using TypeDoc