Hierarchy

Constructors

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.

            schemaName: "UUID"

            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

            • 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 mongoose.Schema.Types.UUID

            • 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 mongoose.Schema.Types.UUID

            • 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 mongoose.Schema.Types.UUID

            • Adds validator(s) for this document path.

              Parameters

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

              Returns mongoose.Schema.Types.UUID

            • 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