Options
All
  • Public
  • Public/Protected
  • All
Menu

Type Parameters

  • T

Hierarchy

Indexable

[other: string]: any

Index

Constructors

Properties

type?: T extends string ? StringSchemaDefinition : T extends number ? NumberSchemaDefinition : T extends boolean ? BooleanSchemaDefinition : T extends NativeDate ? DateSchemaDefinition : T extends Map<any, any> ? { prototype?: SchemaDefinitionProperty<Map<any, any>>; [species]?: SchemaDefinitionProperty<MapConstructor> } : T extends <internal>.Buffer ? { prototype: SchemaDefinitionProperty<<internal>.Buffer>; from?: any; of?: any; isBuffer?: any; isEncoding?: any; byteLength?: any; concat?: any; compare?: any; alloc?: any; allocUnsafe?: any; allocUnsafeSlow?: any; poolSize?: SchemaDefinitionProperty<number>; BYTES_PER_ELEMENT?: SchemaDefinitionProperty<number> } : T extends <internal>.ObjectId ? ObjectIdSchemaDefinition : T extends <internal>.ObjectId[] ? AnyArray<ObjectIdSchemaDefinition> | AnyArray<SchemaTypeOptions<<internal>.ObjectId>> : T extends object[] ? AnyArray<Schema<any, any, any, {}, {}, {}, DefaultSchemaOptions, {}>> | AnyArray<SchemaDefinition<Unpacked<T>>> | AnyArray<SchemaTypeOptions<Unpacked<T>>> : T extends string[] ? AnyArray<StringSchemaDefinition> | AnyArray<SchemaTypeOptions<string>> : T extends number[] ? AnyArray<NumberSchemaDefinition> | AnyArray<SchemaTypeOptions<number>> : T extends boolean[] ? AnyArray<BooleanSchemaDefinition> | AnyArray<SchemaTypeOptions<boolean>> : T extends Function[] ? AnyArray<string | Function> | AnyArray<SchemaTypeOptions<Unpacked<T>>> : Function | T | typeof SchemaType | Schema<any, any, any, {}, {}, {}, DefaultSchemaOptions, {}> | SchemaDefinition<T> | AnyArray<Function>
alias?: string | string[]

Defines a virtual with the given name that gets/sets this path.

Function or object describing how to validate this schematype. See validation docs.

cast?: string

Allows overriding casting logic for this individual path. If a string, the given string overwrites Mongoose's default cast error message.

required?: boolean | (() => boolean) | [boolean, string] | [(() => boolean), string]

If true, attach a required validator to this path, which ensures this path path cannot be set to a nullish value. If a function, Mongoose calls the function and only checks for nullish values if the function returns a truthy value.

default?: DefaultType<T> | ((this: any, doc: any) => DefaultType<T>)

The default value for this path. If a function, Mongoose executes the function and uses the return value as the default.

ref?: string | <internal>.Model<any, {}, {}, {}, any> | ((this: any, doc: any) => string | <internal>.Model<any, {}, {}, {}, any>)

The model that populate() should use if populating this path.

refPath?: string | ((this: any, doc: any) => string)

The path in the document that populate() should use to find the model to use.

select?: number | boolean

Whether to include or exclude this path by default when loading documents using find(), findOne(), etc.

If truthy, Mongoose will build an index on this path when the model is compiled.

unique?: number | boolean

If truthy, Mongoose will build a unique index on this path when the model is compiled. The unique option is not a validator.

immutable?: boolean | ((this: any, doc: any) => boolean)

If truthy, Mongoose will disallow changes to this path once the document is saved to the database for the first time. Read more about immutability in Mongoose here.

sparse?: number | boolean

If truthy, Mongoose will build a sparse index on this path.

text?: any

If truthy, Mongoose will build a text index on this path.

transform?: ((this: any, val: T) => any)

Type declaration

    • (this: any, val: T): any
    • Define a transform function for this individual schema type. Only called when calling toJSON() or toObject().

      Parameters

      • this: any
      • val: T

      Returns any

get?: ((value: any, doc?: SchemaTypeOptions<T>) => T)

Type declaration

set?: ((value: any, priorVal?: T, doc?: SchemaTypeOptions<T>) => any)

Type declaration

enum?: (string | number)[] | readonly (string | number)[] | { values: (string | number)[] | readonly (string | number)[]; message?: string } | {}

array of allowed values for this path. Allowed for strings, numbers, and arrays of strings

subtype?: number

The default subtype associated with this buffer when it is stored in MongoDB. Only allowed for buffer paths

min?: number | NativeDate | [number, string] | [NativeDate, string] | readonly [number, string] | readonly [NativeDate, string]

The minimum value allowed for this path. Only allowed for numbers and dates.

max?: number | NativeDate | [number, string] | [NativeDate, string] | readonly [number, string] | readonly [NativeDate, string]

The maximum value allowed for this path. Only allowed for numbers and dates.

expires?: string | number

Defines a TTL index on this path. Only allowed for dates.

excludeIndexes?: boolean

If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.

_id?: boolean

If set, overrides the child schema's _id option. Only allowed for subdocuments and subdocument arrays.

If set, specifies the type of this map's values. Mongoose will cast this map's values to the given type.

auto?: boolean

If true, uses Mongoose's default _id settings. Only allowed for ObjectIds

match?: RegExp | [RegExp, string] | readonly [RegExp, string]

Attaches a validator that succeeds if the data string matches the given regular expression, and fails otherwise.

lowercase?: boolean

If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().

trim?: boolean

If truthy, Mongoose will add a custom setter that removes leading and trailing whitespace using JavaScript's built-in String#trim().

uppercase?: boolean

If truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase().

minlength?: number | [number, string] | readonly [number, string]

If set, Mongoose will add a custom validator that ensures the given string's length is at least the given number.

maxlength?: number | [number, string] | readonly [number, string]

If set, Mongoose will add a custom validator that ensures the given string's length is at most the given number.

Generated using TypeDoc