Skip to main content
Version: 5.9

@mikro-orm/core

Index

Classes

Enumerations

Functions

Interfaces

Type Aliases

Variables

Type Aliases

AnyEntity

AnyEntity<T>: Partial<T>

Type parameters

  • T = any

Cast

Cast<T, R>: T extends R ? T : R

Type parameters

  • T
  • R

CheckCallback

CheckCallback<T>: (columns: Record<keyof T, string>) => string

Type parameters

  • T

Type declaration

    • (columns: Record<keyof T, string>): string
    • Parameters

      • columns: Record<keyof T, string>

      Returns string

CheckOptions

CheckOptions<T>: CheckConstraint<T>

Type parameters

  • T = any

ConnectionType

ConnectionType: read | write

Constructor

Constructor<T>: new (...args: any[]) => T

Type parameters

  • T = unknown

Type declaration

    • new (...args: any[]): T
    • Parameters

      • rest...args: any[]

      Returns T

DeepPartial

DeepPartial<T>: T & { [ P in keyof T ]?: T[P] extends infer U[] ? DeepPartial<U>[] : T[P] extends Readonly<infer U>[] ? Readonly<DeepPartial<U>>[] : DeepPartial<T[P]> }

Type parameters

  • T

Dictionary

Dictionary<T>: {}

Type parameters

  • T = any

Type declaration

  • [k string]: T

EmbeddableOptions

EmbeddableOptions: { abstract?: boolean; discriminatorColumn?: string; discriminatorMap?: Dictionary<string>; discriminatorValue?: number | string }

Type declaration

  • optionalabstract?: boolean
  • optionaldiscriminatorColumn?: string
  • optionaldiscriminatorMap?: Dictionary<string>
  • optionaldiscriminatorValue?: number | string

EmbeddedOptions

EmbeddedOptions: { array?: boolean; entity?: string | () => AnyEntity | AnyEntity[]; hidden?: boolean; nullable?: boolean; object?: boolean; prefix?: string | boolean; serializedName?: string; serializer?: (value: any) => any; type?: string }

Type declaration

  • optionalarray?: boolean
  • optionalentity?: string | () => AnyEntity | AnyEntity[]
  • optionalhidden?: boolean
  • optionalnullable?: boolean
  • optionalobject?: boolean
  • optionalprefix?: string | boolean
  • optionalserializedName?: string
  • optionalserializer?: (value: any) => any
      • (value: any): any
      • Parameters

        • value: any

        Returns any

  • optionaltype?: string

EntityClass

EntityClass<T>: Function & { prototype: T }

Type parameters

  • T

EntityClassGroup

EntityClassGroup<T>: { entity: EntityClass<T>; schema: EntityMetadata<T> | EntitySchema<T> }

Type parameters

  • T

Type declaration

  • entity: EntityClass<T>
  • schema: EntityMetadata<T> | EntitySchema<T>

EntityDTO

EntityDTO<T>: { [ K in keyof T as ExcludeFunctions<T, K> ]: EntityDTOProp<T[K]> }

Type parameters

  • T

EntityData

EntityData<T>: { [ K in keyof T as ExcludeFunctions<T, K> ]?: EntityDataItem<T[K]> }

Type parameters

  • T

EntityDictionary

EntityDictionary<T>: EntityData<T> & Dictionary

Type parameters

  • T

EntityField

EntityField<T, P>: keyof T | * | AutoPath<T, P, *> | FieldsMap<T, P>

Type parameters

  • T
  • P: string = never

EntityLoaderOptions

EntityLoaderOptions<T, P>: { connectionType?: ConnectionType; convertCustomTypes?: boolean; fields?: readonly EntityField<T, P>[]; filters?: Dictionary<boolean | Dictionary> | string[] | boolean; ignoreLazyScalarProperties?: boolean; lockMode?: Exclude<LockMode, LockMode.OPTIMISTIC>; lookup?: boolean; orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[]; populateWhere?: PopulateHint; refresh?: boolean; schema?: string; strategy?: LoadStrategy; validate?: boolean; where?: FilterQuery<T> }

Type parameters

  • T
  • P: string = never

Type declaration

  • optionalconnectionType?: ConnectionType
  • optionalconvertCustomTypes?: boolean
  • optionalfields?: readonly EntityField<T, P>[]
  • optionalfilters?: Dictionary<boolean | Dictionary> | string[] | boolean
  • optionalignoreLazyScalarProperties?: boolean
  • optionallockMode?: Exclude<LockMode, LockMode.OPTIMISTIC>
  • optionallookup?: boolean
  • optionalorderBy?: QueryOrderMap<T> | QueryOrderMap<T>[]
  • optionalpopulateWhere?: PopulateHint
  • optionalrefresh?: boolean
  • optionalschema?: string
  • optionalstrategy?: LoadStrategy
  • optionalvalidate?: boolean
  • optionalwhere?: FilterQuery<T>

EntityName

EntityName<T>: string | EntityClass<T> | EntitySchema<T, any>

Type parameters

  • T

EntityOptions

EntityOptions<T>: { abstract?: boolean; collection?: string; comment?: string; customRepository?: () => Constructor; discriminatorColumn?: string; discriminatorMap?: Dictionary<string>; discriminatorValue?: number | string; expression?: string | (em: any, where: FilterQuery<T>, options: FindOptions<T, any>) => object; forceConstructor?: boolean; readonly?: boolean; repository?: () => Constructor; schema?: string; tableName?: string; virtual?: boolean }

Type parameters

  • T

Type declaration

  • optionalabstract?: boolean
  • optionalcollection?: string
  • optionalcomment?: string
  • optionalcustomRepository?: () => Constructor
      • (): Constructor
      • Returns Constructor

  • optionaldiscriminatorColumn?: string
  • optionaldiscriminatorMap?: Dictionary<string>
  • optionaldiscriminatorValue?: number | string
  • optionalexpression?: string | (em: any, where: FilterQuery<T>, options: FindOptions<T, any>) => object
  • optionalforceConstructor?: boolean
  • optionalreadonly?: boolean
  • optionalrepository?: () => Constructor
      • (): Constructor
      • shortcut for customRepository


        Returns Constructor

  • optionalschema?: string
  • optionaltableName?: string
  • optionalvirtual?: boolean

EntitySchemaMetadata

EntitySchemaMetadata<T, U>: Omit<Partial<EntityMetadata<T>>, name | properties> & ({ name: string } | { class: Constructor<T>; name?: string }) & { properties?: { [ K in keyof Omit<T, keyof U> as ExcludeFunctions<Omit<T, keyof U>, K> ]-?: EntitySchemaProperty<ExpandProperty<NonNullable<T[K]>>, T> } }

Type parameters

  • T
  • U

EntitySchemaProperty

EntitySchemaProperty<T, O>: ({ reference: ReferenceType.MANY_TO_ONE | m:1 } & TypeDef<T> & ManyToOneOptions<T, O>) | ({ reference: ReferenceType.ONE_TO_ONE | 1:1 } & TypeDef<T> & OneToOneOptions<T, O>) | ({ reference: ReferenceType.ONE_TO_MANY | 1:m } & TypeDef<T> & OneToManyOptions<T, O>) | ({ reference: ReferenceType.MANY_TO_MANY | m:n } & TypeDef<T> & ManyToManyOptions<T, O>) | ({ reference: ReferenceType.EMBEDDED | embedded } & TypeDef<T> & EmbeddedOptions & PropertyOptions<O>) | ({ enum: true } & EnumOptions<O>) | (TypeDef<T> & PropertyOptions<O>)

Type parameters

  • T
  • O

FilterQuery

FilterQuery<T>: ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T>>> | NonNullable<EntityProps<T> & OperatorMap<T>> | FilterQuery<T>[]

Type parameters

  • T

GetRepository

GetRepository<Entity, Fallback>: Entity[typeof EntityRepositoryType] extends EntityRepository<Entity> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback

Type parameters

  • Entity: {}
  • Fallback

IPrimaryKey

IPrimaryKey<T>: T

Type parameters

  • T: IPrimaryKeyValue = IPrimaryKeyValue

IdentifiedReference

IdentifiedReference<T, PK>: true extends IsUnknown<PK> ? Reference<T> : { [ K in Cast<PK, keyof T> ]: T[K] } & Reference<T>
@deprecated

use Ref instead, IdentifiedReference type will be removed in v6


Type parameters

  • T
  • PK: keyof T | unknown = PrimaryProperty<T>

IsUnknown

IsUnknown<T>: T extends unknown ? unknown extends T ? true : never : never

Type parameters

  • T

Loaded

Loaded<T, L>: T & { [ K in keyof T ]: K extends Prefix<L> ? LoadedLoadable<T[K], Loaded<ExtractType<T[K]>, Suffix<L>>> : T[K] }

Type parameters

  • T
  • L: string = never

LoggerNamespace

LoggerNamespace: query | query-params | schema | discovery | info

MigrationsOptions

MigrationsOptions: { allOrNothing?: boolean; disableForeignKeys?: boolean; dropTables?: boolean; emit?: js | ts | cjs; fileName?: (timestamp: string, name?: string) => string; generator?: Constructor<IMigrationGenerator>; glob?: string; migrationsList?: MigrationObject[]; path?: string; pathTs?: string; safe?: boolean; silent?: boolean; snapshot?: boolean; snapshotName?: string; tableName?: string; transactional?: boolean }

Type declaration

  • optionalallOrNothing?: boolean
  • optionaldisableForeignKeys?: boolean
  • optionaldropTables?: boolean
  • optionalemit?: js | ts | cjs
  • optionalfileName?: (timestamp: string, name?: string) => string
      • (timestamp: string, name?: string): string
      • Parameters

        • timestamp: string
        • optionalname: string

        Returns string

  • optionalgenerator?: Constructor<IMigrationGenerator>
  • optionalglob?: string
  • optionalmigrationsList?: MigrationObject[]
  • optionalpath?: string
  • optionalpathTs?: string
  • optionalsafe?: boolean
  • optionalsilent?: boolean
  • optionalsnapshot?: boolean
  • optionalsnapshotName?: string
  • optionaltableName?: string
  • optionaltransactional?: boolean

New

New<T, P>: Loaded<T, P>

Type parameters

  • T
  • P: string = string

ObjectQuery

ObjectQuery<T>: ExpandObject<T> & OperatorMap<T>

Type parameters

  • T

OneToManyOptions

OneToManyOptions<T, O>: ReferenceOptions<T, O> & { entity?: string | () => EntityName<T>; inverseJoinColumn?: string; inverseJoinColumns?: string[]; joinColumn?: string; joinColumns?: string[]; mappedBy: (string & keyof T) | (e: T) => any; orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[]; orphanRemoval?: boolean; referenceColumnName?: string }

Type parameters

  • T
  • O

Options

Options<D>: Pick<MikroORMOptions<D>, Exclude<keyof MikroORMOptions<D>, keyof typeof Configuration.DEFAULTS>> & Partial<MikroORMOptions<D>>

Type parameters

  • D: IDatabaseDriver = IDatabaseDriver

Populate

Populate<T, P>: AutoPath<T, P>[] | boolean

Type parameters

  • T
  • P: string = never

PopulateOptions

PopulateOptions<T>: { all?: boolean; children?: PopulateOptions<T[keyof T]>[]; field: string; strategy?: LoadStrategy }

Type parameters

  • T

Type declaration

  • optionalall?: boolean
  • optionalchildren?: PopulateOptions<T[keyof T]>[]
  • field: string
  • optionalstrategy?: LoadStrategy

Primary

Primary<T>: T extends { [PrimaryKeyType]?: infer PK } ? ReadonlyPrimary<PK> : T extends { _id?: infer PK } ? ReadonlyPrimary<PK> | string : T extends { uuid?: infer PK } ? ReadonlyPrimary<PK> : T extends { id?: infer PK } ? ReadonlyPrimary<PK> : never

Type parameters

  • T

PrimaryProperty

PrimaryProperty<T>: T extends { [PrimaryKeyProp]?: infer PK } ? PK : T extends { _id?: any } ? _id | string : T extends { uuid?: any } ? uuid : T extends { id?: any } ? id : never

Type parameters

  • T

PropertyOptions

PropertyOptions<T>: { autoincrement?: boolean; check?: string | CheckCallback<T>; columnType?: ColumnType | AnyString; comment?: string; concurrencyCheck?: boolean; customOrder?: string[] | number[] | boolean[]; customType?: Type<any>; default?: string | string[] | number | number[] | boolean | null; defaultRaw?: string; extra?: string; fieldName?: string; fieldNames?: string[]; formula?: string | (alias: string) => string; getter?: boolean; hidden?: boolean; hydrate?: boolean; ignoreSchemaChanges?: (type | extra)[]; index?: boolean | string; lazy?: boolean; length?: number; name?: string; nullable?: boolean; onCreate?: (entity: T) => any; onUpdate?: (entity: T) => any; persist?: boolean; precision?: number; primary?: boolean; returning?: boolean; scale?: number; serializedName?: string; serializedPrimaryKey?: boolean; serializer?: (value: any) => any; setter?: boolean; trackChanges?: boolean; type?: keyof typeof types | ObjectId | Date | Constructor<AnyEntity> | Constructor<Type<any>> | Type<any> | () => unknown | ColumnType | AnyString; unique?: boolean | string; unsigned?: boolean; version?: boolean }

Type parameters

  • T

Type declaration

  • optionalautoincrement?: boolean

    Explicitly specify the auto increment of the primary key.

  • optionalcheck?: string | CheckCallback<T>

    Specify column with check constraints. (Postgres driver only)

    @see
  • optionalcolumnType?: ColumnType | AnyString

    Specify exact database column type for Generator. (SQL only)

  • optionalcomment?: string

    Specify comment of column for Generator. (SQL only)

  • optionalconcurrencyCheck?: boolean

    Set to true to enable Locking via concurrency fields.

  • optionalcustomOrder?: string[] | number[] | boolean[]

    Specify a custom order based on the values. (SQL only)

  • optionalcustomType?: Type<any>

    Explicitly specify the mapped type instance for this property.

    @see
  • optionaldefault?: string | string[] | number | number[] | boolean | null

    Specify default column value for Generator. This is a runtime value, assignable to the entity property. (SQL only)

  • optionaldefaultRaw?: string

    Specify SQL functions for Generator. (SQL only) Since v4 you should use defaultRaw for SQL functions. e.g. now()

  • optionalextra?: string

    mysql only

  • optionalfieldName?: string

    Specify database column name for this property.

    @see
  • optionalfieldNames?: string[]

    Specify database column names for this property. Same as fieldName but for composite FKs.

    @see
  • optionalformula?: string | (alias: string) => string

    Set to map some SQL snippet for the entity.

    @see
  • optionalgetter?: boolean

    Set true to define the properties as getter. (virtual)

    @example
    @Property({ getter: true })
    get fullName() {
    return this.firstName + this.lastName;
    }
  • optionalhidden?: boolean

    Set to true to omit the property when Serializing.

  • optionalhydrate?: boolean

    Set false to disable hydration of this property. Useful for persisted getters.

  • optionalignoreSchemaChanges?: (type | extra)[]

    Set to avoid a perpetual diff from the Generator when columns are generated.

    @see
  • optionalindex?: boolean | string

    Explicitly specify index on a property.

  • optionallazy?: boolean

    Set to omit the property from the select clause for lazy loading.

    @see
  • optionallength?: number

    Set length of database column, used for datetime/timestamp/varchar column types for Generator. (SQL only)

  • optionalname?: string

    Alias for fieldName.

  • optionalnullable?: boolean

    Set column as nullable for Generator.

  • optionalonCreate?: (entity: T) => any
      • (entity: T): any
      • Automatically set the property value when entity gets created, executed during flush operation.


        Parameters

        • entity: T

        Returns any

  • optionalonUpdate?: (entity: T) => any
      • (entity: T): any
      • Automatically update the property value every time entity gets updated, executed during flush operation.


        Parameters

        • entity: T

        Returns any

  • optionalpersist?: boolean

    Set false to define Property.

  • optionalprecision?: number

    Set precision of database column to represent the number of significant digits. (SQL only)

  • optionalprimary?: boolean

    Set true to define entity's unique primary key identifier. Alias for @PrimaryKey() decorator

    @see
  • optionalreturning?: boolean

    Add the property to the returning statement.

  • optionalscale?: number

    Set scale of database column to represents the number of digits after the decimal point. (SQL only)

  • optionalserializedName?: string

    Specify name of key for the serialized value.

  • optionalserializedPrimaryKey?: boolean

    Set to define serialized primary key for MongoDB. (virtual) Alias for @SerializedPrimaryKey() decorator.

    @see
  • optionalserializer?: (value: any) => any
  • optionalsetter?: boolean

    Set true to define the properties as setter. (virtual)

    @example
    @Property({ setter: true })
    set address(value: string) {
    this._address = value.toLocaleLowerCase();
    }
  • optionaltrackChanges?: boolean

    Set false to disable change tracking on a property level.

    @see
  • optionaltype?: keyof typeof types | ObjectId | Date | Constructor<AnyEntity> | Constructor<Type<any>> | Type<any> | () => unknown | ColumnType | AnyString
  • optionalunique?: boolean | string

    Set column as unique for Generator. (SQL only)

  • optionalunsigned?: boolean

    Set column as unsigned for Generator. (SQL only)

  • optionalversion?: boolean

    Set to true to enable Locking via version field. (SQL only)

QBFilterQuery

QBFilterQuery<T>: ObjectQuery<T> | Dictionary

Type parameters

  • T = any

QBQueryOrderMap

QBQueryOrderMap<T>: QueryOrderMap<T> | Dictionary

Type parameters

  • T

QueryOrderKeys

QueryOrderKeys<T>: QueryOrderKeysFlat | QueryOrderMap<T>

Type parameters

  • T

QueryOrderKeysFlat

QueryOrderKeysFlat: QueryOrder | QueryOrderNumeric | keyof typeof QueryOrder

QueryOrderMap

QueryOrderMap<T>: { [ K in keyof T as ExcludeFunctions<T, K> ]?: QueryOrderKeys<ExpandProperty<T[K]>> }

Type parameters

  • T

Ref

Ref<T, PK>: IdentifiedReference<T, PK>

Shortcut for IdentifiedReference.


Type parameters

  • T
  • PK: keyof T | unknown = PrimaryProperty<T>

Rel

Rel<T>: T

Identity type that can be used to get around issues with cycles in bidirectional relations.


Type parameters

  • T

RequiredEntityData

RequiredEntityData<T>: EntityData<T> & { [ K in keyof T as RequiredKeys<T, K> ]: T[K] | EntityDataProp<T[K]> }

Type parameters

  • T

SeederOptions

SeederOptions: { defaultSeeder?: string; emit?: js | ts; fileName?: (className: string) => string; glob?: string; path?: string; pathTs?: string }

Type declaration

  • optionaldefaultSeeder?: string
  • optionalemit?: js | ts
  • optionalfileName?: (className: string) => string
      • (className: string): string
      • Parameters

        • className: string

        Returns string

  • optionalglob?: string
  • optionalpath?: string
  • optionalpathTs?: string

Transaction

Transaction<T>: T

Type parameters

  • T = any

TransactionEventType

TransactionEventType: EventType.beforeTransactionStart | EventType.afterTransactionStart | EventType.beforeTransactionCommit | EventType.afterTransactionCommit | EventType.beforeTransactionRollback | EventType.afterTransactionRollback

Variables

constARRAY_OPERATORS

ARRAY_OPERATORS: string[] = ...

constEntityManagerType

EntityManagerType: typeof EntityManagerType = ...

constEntityRepositoryType

EntityRepositoryType: typeof EntityRepositoryType = ...

constJsonProperty

JsonProperty: typeof JsonProperty = ...

constObjectBindingPattern

ObjectBindingPattern: typeof ObjectBindingPattern = ...

constOptionalProps

OptionalProps: typeof OptionalProps = ...

constPrimaryKeyProp

PrimaryKeyProp: typeof PrimaryKeyProp = ...

constPrimaryKeyType

PrimaryKeyType: typeof PrimaryKeyType = ...

constSCALAR_TYPES

SCALAR_TYPES: string[] = ...

constt

t: { array: typeof ArrayType; bigint: typeof BigIntType; blob: typeof BlobType; boolean: typeof BooleanType; date: typeof DateType; datetime: typeof DateTimeType; decimal: typeof DecimalType; double: typeof DoubleType; enum: typeof EnumType; enumArray: typeof EnumArrayType; float: typeof FloatType; integer: typeof IntegerType; json: typeof JsonType; mediumint: typeof MediumIntType; smallint: typeof SmallIntType; string: typeof StringType; text: typeof TextType; time: typeof TimeType; tinyint: typeof TinyIntType; uint8array: typeof Uint8ArrayType; unknown: typeof UnknownType; uuid: typeof UuidType } = types

Type declaration

  • array: typeof ArrayType
  • bigint: typeof BigIntType
  • blob: typeof BlobType
  • boolean: typeof BooleanType
  • date: typeof DateType
  • datetime: typeof DateTimeType
  • decimal: typeof DecimalType
  • double: typeof DoubleType
  • enum: typeof EnumType
  • enumArray: typeof EnumArrayType
  • float: typeof FloatType
  • integer: typeof IntegerType
  • json: typeof JsonType
  • mediumint: typeof MediumIntType
  • smallint: typeof SmallIntType
  • string: typeof StringType
  • text: typeof TextType
  • time: typeof TimeType
  • tinyint: typeof TinyIntType
  • uint8array: typeof Uint8ArrayType
  • unknown: typeof UnknownType
  • uuid: typeof UuidType

consttypes

types: { array: typeof ArrayType; bigint: typeof BigIntType; blob: typeof BlobType; boolean: typeof BooleanType; date: typeof DateType; datetime: typeof DateTimeType; decimal: typeof DecimalType; double: typeof DoubleType; enum: typeof EnumType; enumArray: typeof EnumArrayType; float: typeof FloatType; integer: typeof IntegerType; json: typeof JsonType; mediumint: typeof MediumIntType; smallint: typeof SmallIntType; string: typeof StringType; text: typeof TextType; time: typeof TimeType; tinyint: typeof TinyIntType; uint8array: typeof Uint8ArrayType; unknown: typeof UnknownType; uuid: typeof UuidType } = ...

Type declaration

  • array: typeof ArrayType
  • bigint: typeof BigIntType
  • blob: typeof BlobType
  • boolean: typeof BooleanType
  • date: typeof DateType
  • datetime: typeof DateTimeType
  • decimal: typeof DecimalType
  • double: typeof DoubleType
  • enum: typeof EnumType
  • enumArray: typeof EnumArrayType
  • float: typeof FloatType
  • integer: typeof IntegerType
  • json: typeof JsonType
  • mediumint: typeof MediumIntType
  • smallint: typeof SmallIntType
  • string: typeof StringType
  • text: typeof TextType
  • time: typeof TimeType
  • tinyint: typeof TinyIntType
  • uint8array: typeof Uint8ArrayType
  • unknown: typeof UnknownType
  • uuid: typeof UuidType