Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

  • new Date(path: string, options?: AnyObject, instance?: string): Date
  • SchemaType constructor

    Parameters

    • path: string
    • Optional options: AnyObject
    • Optional instance: string

    Returns Date

Methods

  • cast(caster?: boolean | Function): Function
  • Get/set the function used to cast arbitrary values to this type.

    Parameters

    • Optional caster: boolean | Function

    Returns Function

  • checkRequired(checkRequired?: ((v: any) => boolean)): ((v: any) => boolean)
  • Parameters

    • Optional checkRequired: ((v: any) => boolean)
        • (v: any): boolean
        • Parameters

          • v: any

          Returns boolean

    Returns ((v: any) => boolean)

      • (v: any): boolean
      • Parameters

        • v: any

        Returns boolean

  • set(option: string, value: any): void
  • Sets a default option for this schema type.

    Parameters

    • option: string
    • value: any

    Returns void

  • get(getter: ((value: any) => any)): void
  • Attaches a getter for all instances of this schema type.

    Parameters

    • getter: ((value: any) => any)
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns void

  • cast(val: any, doc: <internal>.Document<any, any, any>, init: boolean, prev?: any, options?: any): any
  • Cast val to this schema type. Each class that inherits from schema type should implement this function.

    Parameters

    • val: any
    • doc: <internal>.Document<any, any, any>
    • init: boolean
    • Optional prev: any
    • Optional options: any

    Returns any

  • default(val: any): any
  • Sets a default value for this SchemaType.

    Parameters

    • val: any

    Returns any

  • get(fn: Function): Date
  • Adds a getter to this schematype.

    Parameters

    • fn: Function

    Returns Date

  • immutable(bool: boolean): Date
  • Defines this path as immutable. Mongoose prevents you from changing immutable paths unless the parent document has isNew: true.

    Parameters

    • bool: boolean

    Returns Date

  • index(options: any): Date
  • Declares the index options for this schematype.

    Parameters

    • options: any

    Returns Date

  • Set the model that this path refers to. This is the option that populate looks at to determine the foreign collection it should query.

    Parameters

    Returns Date

  • required(required: boolean, message?: string): Date
  • Adds a required validator to this SchemaType. The validator gets added to the front of this SchemaType's validators array using unshift().

    Parameters

    • required: boolean
    • Optional message: string

    Returns Date

  • select(val: boolean): Date
  • Sets default select() behavior for this path.

    Parameters

    • val: boolean

    Returns Date

  • set(fn: Function): Date
  • Adds a setter to this schematype.

    Parameters

    • fn: Function

    Returns Date

  • sparse(bool: boolean): Date
  • Declares a sparse index.

    Parameters

    • bool: boolean

    Returns Date

  • text(bool: boolean): Date
  • Declares a full text index.

    Parameters

    • bool: boolean

    Returns Date

  • transform(fn: ((value: any) => any)): Date
  • Defines a custom function for transforming this path when converting a document to JSON.

    Parameters

    • fn: ((value: any) => any)
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Date

  • unique(bool: boolean): Date
  • Declares an unique index.

    Parameters

    • bool: boolean

    Returns Date

  • validate(obj: RegExp | ((this: any, value: any, validatorProperties?: Validator) => any), errorMsg?: string, type?: string): Date
  • Adds validator(s) for this document path.

    Parameters

    • obj: RegExp | ((this: any, value: any, validatorProperties?: Validator) => any)
    • Optional errorMsg: string
    • Optional type: string

    Returns Date

  • expires(when: string | number): Date
  • Declares a TTL index (rounded to the nearest second) for Date types only.

    Parameters

    • when: string | number

    Returns Date

  • Sets a maximum date validator.

    Parameters

    Returns Date

  • Sets a minimum date validator.

    Parameters

    Returns Date

Properties

OptionsConstructor: SchemaTypeOptions<any>

The class that Mongoose uses internally to instantiate this SchemaType's options property.

instance: string

String representation of what type this is, like 'ObjectID' or 'Number'

isRequired?: boolean

True if this SchemaType has a required validator. False otherwise.

options: AnyObject

The options this SchemaType was instantiated with

path: string

The path to this SchemaType in a Schema.

schema: Schema<any, <internal>.Model<any, any, any, any, any>, {}, {}, {}, {}, DefaultSchemaOptions, {}>

The schema this SchemaType instance is part of

validators: Validator[]

The validators that Mongoose should run to validate properties at this SchemaType's path.

schemaName: "Date"

This schema type's name, to defend against minifiers that mangle function names.

defaultOptions: <internal>.Record<string, any>

Default options for this SchemaType

Generated using TypeDoc