Hierarchy

Constructors

  • SchemaType constructor

    Parameters

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

    Returns Boolean

Properties

OptionsConstructor: SchemaTypeOptions<any, any>

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

defaultOptions: Record<string, any>

Default options for this SchemaType

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, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, DefaultSchemaOptions, {}, mongoose.Document<unknown, {}, FlatRecord<{}>> & FlatRecord<{}> & Required<{
    _id: unknown;
}>>

The schema this SchemaType instance is part of

Type declaration

    Type declaration

      Type declaration

        Type declaration

          Type declaration

            validators: mongoose.Validator[]

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

            convertToFalse: Set<any>

            Configure which values get casted to false.

            convertToTrue: Set<any>

            Configure which values get casted to true.

            schemaName: "Boolean"

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

            Methods

            • Cast val to this schema type. Each class that inherits from schema type should implement this function.

              Parameters

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

              Returns any

            • Sets a default value for this SchemaType.

              Parameters

              • val: any

              Returns any

            • Adds a getter to this schematype.

              Parameters

              • fn: Function

              Returns Boolean

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

              Parameters

              • bool: boolean

              Returns Boolean

            • Declares the index options for this schematype.

              Parameters

              • options: any

              Returns Boolean

            • 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

              • ref: string | boolean | mongoose.Model<any, {}, {}, {}, any, any>

              Returns Boolean

            • 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
                Optional

              Returns Boolean

            • Sets default select() behavior for this path.

              Parameters

              • val: boolean

              Returns Boolean

            • Adds a setter to this schematype.

              Parameters

              • fn: Function

              Returns Boolean

            • Declares a sparse index.

              Parameters

              • bool: boolean

              Returns Boolean

            • Declares a full text index.

              Parameters

              • bool: boolean

              Returns Boolean

            • Defines a custom function for transforming this path when converting a document to JSON.

              Parameters

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

                    • value: any

                    Returns any

              Returns Boolean

            • Declares an unique index.

              Parameters

              • bool: boolean

              Returns Boolean

            • Adds validator(s) for this document path.

              Parameters

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

              Returns Boolean

            • Get/set the function used to cast arbitrary values to this type.

              Parameters

              • Optional caster: boolean | Function
                Optional

              Returns Function

            • Parameters

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

                    • v: any

                    Returns boolean

              Returns ((v) => boolean)

                • (v): boolean
                • Parameters

                  • v: any

                  Returns boolean

            • Attaches a getter for all instances of this schema type.

              Parameters

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

                    • value: any

                    Returns any

              Returns void

            • Sets a default option for this schema type.

              Parameters

              • option: string
              • value: any

              Returns void

            Generated using TypeDoc