Interface MapPropOptions

Options For Map's

Hierarchy

Properties

_id?: boolean

Should subdocuments get their own id?

Default

true (Implicitly)
addNullToEnum?: boolean

Add "null" to the enum array Note: Custom Typegoose Option

alias?: string | string[]

Give the Property an alias in the output

Note: you should include the alias as a variable in the class, but not with a prop decorator

Example

class Dummy {
@prop({ alias: "helloWorld" })
public hello: string; // normal, with @prop
public helloWorld: string; // is just for type Completion, will not be included in the DB
}
allowMixed?: Severity

Set Custom "warnMixed" Severity for a specific property Overwrites Severity set in "modelOptions" for a specific property Note: Custom Typegoose Option

auto?: boolean

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

Note: Copied from mongoose's "index.d.ts"#SchemaTypeOptions

autopopulate?: boolean | Function | KeyStringAny

This option as only an effect when the plugin mongoose-autopopulate is used

default?: any

Give the Property a default Value

Set the Nested Discriminators

Note: "_id: false" as a prop option doesn't work here

Note: Custom Typegoose Option

enum?: EnumCombinedType | DeferredFunc<EnumCombinedType> | {
    message?: string;
    values: DeferredFunc<EnumValues>;
}

Only accept Values from the Enum(|Array)

Type declaration

excludeIndexes?: boolean

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

Note: Copied from mongoose's "index.d.ts"#SchemaTypeOptions

expires?: string | number

Should this property have an "expires" index?

get?: ((value, doc?) => any)

Type declaration

    • (value, doc?): any
    • Set a Getter (Non-Virtual) to Post-process your value (when using get/set both are required) Please note that the option type is required, if get/set saves a different value than what is defined

      Parameters

      • value: any

        The Value that needs to get modified

      • Optional doc: SchemaTypeOptions<any, any>
        Optional

      Returns any

      The Value, but modified OR anything

      Example

      function setHello(val: string): string {
      return val.toLowerCase()
      }
      function getHello(val: string): string {
      return val.toUpperCase();
      }
      class Dummy {
      @prop({ set: setHello, get: getHello }) // many options can be used, like required
      public hello: string;
      }
immutable?: boolean | ((this, doc) => boolean)

Make a property read-only

Type declaration

    • (this, doc): boolean
    • Parameters

      • this: any
      • doc: any

      Returns boolean

Example

class SomeClass {
@prop({ immutable: true })
public someprop: Readonly<string>;
}

Should this property have an index? Note: don't use this if you want to do a compound index

innerOptions?: KeyStringAny

Use this to define inner-options Use this if the auto-mapping is not correct or for plugin options

Please open a new issue if some option is mismatched or not existing / mapped

of?: never
outerOptions?: KeyStringAny

Use this to define outer-options Use this if the auto-mapping is not correct or for plugin options

Please open a new issue if some option is mismatched or not existing / mapped

ref?: string | AnyParamConstructor<any> | DeferredFunc<string | AnyParamConstructor<any> | DynamicStringFunc<any>>

Reference another Document (you should use Ref as Prop type)

refPath?: string

Take the Path and try to resolve it to a Model

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

is this value required?

Type declaration

    • (this): boolean
    • Parameters

      • this: any

      Returns boolean

Default

false (Implicitly)
select?: number | boolean

include this value?

Default

true (Implicitly)
set?: ((value, priorVal?, doc?) => any)

Type declaration

    • (value, priorVal?, doc?): any
    • Set a Setter (Non-Virtual) to pre-process your value (when using get/set both are required) Please note that the option type is required, if get/set saves a different value than what is defined

      Parameters

      • value: any

        The Value that needs to get modified

      • Optional priorVal: any
        Optional
      • Optional doc: SchemaTypeOptions<any, any>
        Optional

      Returns any

      The Value, but modified OR anything

      Example

      function setHello(val: string): string {
      return val.toLowerCase()
      }
      function getHello(val: string): string {
      return val.toUpperCase();
      }
      class Dummy {
      @prop({ set: setHello, get: getHello }) // many options can be used, like required
      public hello: string;
      }
sparse?: number | boolean

Should this property have a "sparse" index?

subtype?: number

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

Note: Copied from mongoose's "index.d.ts"#SchemaTypeOptions

text?: any

Should this property have a "text" index?

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

Type declaration

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

      Note: Copied from mongoose's "index.d.ts"#SchemaTypeOptions

      Parameters

      • this: any
      • val: any

      Returns any

type?: unknown

This may be needed if get/set is used (this sets the type how it is saved to the DB)

unique?: number | boolean

Should this property have a "unique" index?

validate?: SchemaValidator<any> | AnyArray<SchemaValidator<any>>

Give a Validator RegExp or Function

Generated using TypeDoc