Skip to main content
Version: 6.4

@mikro-orm/core

Index

Classes

Enumerations

Functions

Interfaces

Type Aliases

Variables

Type Aliases

AnyEntity

AnyEntity<T>: Partial<T>

Type parameters

  • T = any

AutoPath

AutoPath<O, P, E, D>: P extends boolean ? P : [D] extends [never] ? never : P extends any ? P extends string ? ((P & `${string}.`) extends never ? P : P & `${string}.`) extends infer Q ? Q extends `${infer A}.${infer B}` ? A extends StringKeys<O, E> ? `${A}.${AutoPath<NonNullable<GetStringKey<..., ..., ...>>, B, E, Prev[D]>}` : never : Q extends StringKeys<O, E> ? (NonNullable<...> extends unknown ? Exclude<..., ...> : never) | (StringKeys<..., ...> extends never ? never : `${...}.`) : StringKeys<O, E> | `${CollectionKeys<O>}:ref` : never : never : never

Type parameters

  • O
  • P: string | boolean
  • E: string = never
  • D: Prev[number] = 9

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

DefineConfig

DefineConfig<T>: T & { [___config]?: 1 }

Type parameters

Dictionary

Dictionary<T>: {}

Type parameters

  • T = any

Type declaration

    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[]; groups?: string[]; hidden?: boolean; nullable?: boolean; object?: boolean; persist?: boolean; prefix?: string | boolean; prefixMode?: EmbeddedPrefixMode; serializedName?: string; serializer?: (value: any) => any; type?: string }

    Type declaration

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

          • value: any

          Returns any

    • optionaltype?: string

    EmbeddedPrefixMode

    EmbeddedPrefixMode: absolute | relative

    With absolute the prefix is set at the root of the entity (regardless of the nesting level)

    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

    EntityData

    EntityData<T, C>: { [ K in EntityKey<T> ]?: EntityDataItem<T[K], C> }

    Type parameters

    • T
    • C: boolean = false

    EntityDictionary

    EntityDictionary<T>: EntityData<T> & Record<any, any>

    Type parameters

    • T

    EntityDTO

    EntityDTO<T, C>: { [ K in keyof T as DTORequiredKeys<T, K> ]: EntityDTOProp<T, T[K], C> | AddOptional<T[K]> } & { [ K in keyof T as DTOOptionalKeys<T, K> ]?: EntityDTOProp<T, T[K], C> | AddOptional<T[K]> }

    Type parameters

    EntityField

    EntityField<T, P>: keyof T | PopulatePath.ALL | AutoPath<T, P, `${PopulatePath.ALL}`>

    Type parameters

    • T
    • P: string = PopulatePath.ALL

    EntityKey

    EntityKey<T, B>: string & { [ K in keyof T ]-?: CleanKeys<T, K, B> extends never ? never : K }[keyof T]

    Type parameters

    • T = unknown
    • B: boolean = false

    EntityLoaderOptions

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

    Type parameters

    • Entity
    • Fields: string = PopulatePath.ALL
    • Excludes: string = never

    Type declaration

    EntityName

    EntityName<T>: string | EntityClass<T> | EntitySchema<T, any> | { name: string }

    Type parameters

    • T

    EntityOptions

    EntityOptions<T>: { abstract?: boolean; collection?: string; comment?: string; discriminatorColumn?: string; discriminatorMap?: Dictionary<string>; discriminatorValue?: number | string; expression?: string | (em: any, where: FilterQuery<T>, options: FindOptions<T, any, any, 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
    • optionaldiscriminatorColumn?: string
    • optionaldiscriminatorMap?: Dictionary<string>
    • optionaldiscriminatorValue?: number | string
    • optionalexpression?: string | (em: any, where: FilterQuery<T>, options: FindOptions<T, any, any, any>) => object
    • optionalforceConstructor?: boolean
    • optionalreadonly?: boolean
    • optionalrepository?: () => Constructor
    • optionalschema?: string
    • optionaltableName?: string
    • optionalvirtual?: boolean

    EntityProps

    EntityProps<T>: { -readonly [ K in EntityKey<T> ]?: T[K] }

    Type parameters

    • T

    EntityRef

    EntityRef<T>: true extends IsUnknown<PrimaryProperty<T>> ? Reference<T> : IsAny<T> extends true ? Reference<T> : { [ K in PrimaryProperty<T> & keyof T ]: T[K] } & Reference<T>

    Alias for Reference<T> & { id: number } (see Ref).


    Type parameters

    • T: object

    EntitySchemaMetadata

    EntitySchemaMetadata<Entity, Base>: Omit<Partial<EntityMetadata<Entity>>, name | properties | extends> & ({ name: string } | { class: EntityClass<Entity>; name?: string }) & { extends?: string | EntitySchema<Base> } & { properties?: { [ Key in keyof OmitBaseProps<Entity, Base> as CleanKeys<OmitBaseProps<Entity, Base>, Key> ]-?: EntitySchemaProperty<ExpandProperty<NonNullable<Entity[Key]>>, Entity> } }

    Type parameters

    • Entity
    • Base = never

    EntitySchemaProperty

    EntitySchemaProperty<Target, Owner>: ({ kind: ReferenceKind.MANY_TO_ONE | m:1 } & TypeDef<Target> & ManyToOneOptions<Owner, Target>) | ({ kind: ReferenceKind.ONE_TO_ONE | 1:1 } & TypeDef<Target> & OneToOneOptions<Owner, Target>) | ({ kind: ReferenceKind.ONE_TO_MANY | 1:m } & TypeDef<Target> & OneToManyOptions<Owner, Target>) | ({ kind: ReferenceKind.MANY_TO_MANY | m:n } & TypeDef<Target> & ManyToManyOptions<Owner, Target>) | ({ kind: ReferenceKind.EMBEDDED | embedded } & EmbeddedTypeDef<Target> & EmbeddedOptions & PropertyOptions<Owner>) | ({ enum: true } & EnumOptions<Owner>) | (TypeDef<Target> & PropertyOptions<Owner>)

    Type parameters

    • Target
    • Owner

    EntityType

    EntityType<T>: T | LoadedEntityType<T>

    Type parameters

    • T

    EntityValue

    EntityValue<T>: T[EntityKey<T>]

    Type parameters

    • T

    ExpandHint

    ExpandHint<T, L>: L | AddEager<T>

    Type parameters

    • T
    • L: string

    ExpandProperty

    ExpandProperty<T>: T extends Reference<infer U> ? NonNullable<U> : T extends Collection<infer U, any> ? NonNullable<U> : T extends infer U[] ? NonNullable<U> : NonNullable<T>

    Type parameters

    • T

    ExpandQuery

    ExpandQuery<T>: T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>

    Type parameters

    • T

    ExpandScalar

    ExpandScalar<T>: null | (T extends string ? T | RegExp : T extends Date ? Date | string : T extends bigint ? bigint | string | number : T)

    Type parameters

    • T

    FilterItemValue

    FilterItemValue<T>: T | ExpandScalar<T> | Primary<T>

    Type parameters

    • T

    FilterKey

    FilterKey<T>: keyof FilterQuery<T>

    Type parameters

    • T

    FilterObject

    FilterObject<T>: { -readonly [ K in EntityKey<T> ]?: ExpandQuery<ExpandProperty<T[K]>> | FilterValue<ExpandProperty<T[K]>> | null }

    Type parameters

    • T

    FilterOptions

    FilterOptions: Dictionary<boolean | Dictionary> | string[] | boolean

    FilterQuery

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

    Type parameters

    • T

    FilterValue

    FilterValue<T>: OperatorMap<FilterItemValue<T>> | FilterItemValue<T> | FilterItemValue<T>[] | null

    Type parameters

    • T

    FromEntityType

    FromEntityType<T>: T extends LoadedEntityType<infer U> ? U : T

    Type parameters

    • T

    GetRepository

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

    Type parameters

    • Entity: {}
    • Fallback

    Hidden

    Hidden<T>: T & { [___hidden]?: 1 }

    Type parameters

    • T = unknown

    ImportsResolver

    ImportsResolver: (alias: string, basePath: string, extension: .js | , originFileName: string) => { name: string; path: string } | undefined

    Type declaration

      • (alias: string, basePath: string, extension: .js | , originFileName: string): { name: string; path: string } | undefined
      • Parameters

        • alias: string
        • basePath: string
        • extension: .js |
        • originFileName: string

        Returns { name: string; path: string } | undefined

    IPrimaryKey

    IPrimaryKey<T>: T

    Type parameters

    • T: IPrimaryKeyValue = IPrimaryKeyValue

    IsSubset

    IsSubset<T, U>: keyof U extends keyof T ? {} : Dictionary extends U ? {} : { [ K in keyof U as K extends keyof T ? never : CleanKeys<U, K> ]: never }

    Type parameters

    • T
    • U

    IsUnknown

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

    Type parameters

    • T

    IType

    IType<Runtime, Raw, Serialized>: Runtime & { __raw?: Raw; __runtime?: Runtime; __serialized?: Serialized }

    Type parameters

    • Runtime
    • Raw
    • Serialized = Raw

    Loaded

    Loaded<T, L, F, E>: LoadedInternal<T, L, F, E> & { [___loadedType]?: T }

    Represents entity with its loaded relations (populate hint) and selected properties (fields hint).


    Type parameters

    • T
    • L: string = never
    • F: string = *
    • E: string = never

    LoggerNamespace

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

    LoggingOptions

    LoggingOptions: Pick<LogContext, label | enabled | debugMode>

    Logger options to modify format output and overrides, including a label and additional properties that can be accessed by custom loggers.

    Differs from LoggerOptions in terms of how they are used; this type is primarily a public type meant to be used within methods like em.find().

    @example
    await em.findOne(User, 1, { logger: { label: 'user middleware' } };
    // [query] (user middleware) select * from user where id = 1;

    MaybePromise

    MaybePromise<T>: T | Promise<T>

    Type parameters

    • T

    MergeLoaded

    MergeLoaded<T, U, P, F, E, R>: T extends Loaded<U, infer PP, infer FF, infer EE> ? string extends FF ? Loaded<T, P, F, AnyStringToNever<EE> | E> : string extends P ? Loaded<U, never, F | (FF & string), MergeExcludes<F | (FF & string), EE | E>> : Loaded<U, P | AnyStringToNever<PP>, MergeFields<F, AnyStringToNever<FF>, P, PP>, MergeExcludes<MergeFields<F, AnyStringToNever<FF>, P, PP>, (R extends true ? never : EE) | E>> : Loaded<T, P, F>

    Type parameters

    • T
    • U
    • P: string
    • F: string
    • E: string
    • R: boolean = false

    MergeSelected

    MergeSelected<T, U, F>: T extends Loaded<infer TT, infer P, infer FF, infer E> ? IsNever<Exclude<E, F>> extends true ? Loaded<TT, P, AnyStringToNever<F> | AnyStringToNever<FF>> : Loaded<TT, AnyStringToNever<P>, AnyStringToNever<FF>, AnyStringToNever<Exclude<E, F>>> : T

    Type parameters

    • T
    • U
    • F: string

    MetadataProcessor

    MetadataProcessor: (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>

    Type declaration

    MigrateOptions

    MigrateOptions: { from?: string | number; migrations?: string[]; to?: string | number; transaction?: Transaction }

    Type declaration

    • optionalfrom?: string | number
    • optionalmigrations?: string[]
    • optionalto?: string | number
    • optionaltransaction?: Transaction

    MigrationResult

    MigrationResult: { code: string; diff: MigrationDiff; fileName: string }

    Type declaration

    MigrationRow

    MigrationRow: { executed_at: Date; name: string }

    Type declaration

    • executed_at: Date
    • name: string

    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 | Constructor<Migration>)[]; 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 | Constructor<Migration>)[]
    • optionalpath?: string
    • optionalpathTs?: string
    • optionalsafe?: boolean
    • optionalsilent?: boolean
    • optionalsnapshot?: boolean
    • optionalsnapshotName?: string
    • optionaltableName?: string
    • optionaltransactional?: boolean

    MigratorEvent

    MigratorEvent: migrating | migrated | reverting | reverted

    New

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

    Type parameters

    • T
    • P: string = string

    NoInfer

    NoInfer<T>: [T][T extends any ? 0 : never]

    Type parameters

    • T

    ObjectQuery

    ObjectQuery<T>: OperatorMap<T> & FilterObject<T>

    Type parameters

    • T

    Opt

    Opt<T>: T & { [___optional]?: 1 }

    Type parameters

    • T = unknown

    Options

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

    OrderDefinition

    OrderDefinition<T>: (QueryOrderMap<T> & { 0?: never }) | QueryOrderMap<T>[]

    Type parameters

    • T

    Populate

    Populate<T, P>: readonly AutoPath<T, P, `${PopulatePath}`>[] | false

    Type parameters

    • T
    • P: string = never

    PopulateOptions

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

    Type parameters

    • T

    Type declaration

    Primary

    Primary<T>: IsAny<T> extends true ? any : T extends { [PrimaryKeyProp]?: infer PK } ? PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends keyof T[] ? ReadonlyPrimary<PrimaryPropToType<T, PK>> : PK : T extends { _id?: infer PK } ? ReadonlyPrimary<PK> | string : T extends { uuid?: infer PK } ? ReadonlyPrimary<PK> : T extends { id?: infer PK } ? ReadonlyPrimary<PK> : T

    Type parameters

    • T

    PrimaryProperty

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

    Type parameters

    • T

    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 EntityKey<T> ]?: QueryOrderKeys<ExpandProperty<T[K]>> }

    Type parameters

    • T

    Ref

    Ref<T>: T extends any ? IsAny<T> extends true ? Reference<T & object> : T extends Scalar ? ScalarReference<T> : EntityRef<T & object> : never

    Ref type represents a Reference instance, and adds the primary keys to its prototype automatically, so you can do ref.id instead of ref.unwrap().id. It resolves to either ScalarRef or EntityRef, based on the type argument.


    Type parameters

    • T

    Rel

    Rel<T>: T

    Identity type that can be used to get around issues with cycles in bidirectional relations. It will disable reflect-metadata inference.


    Type parameters

    • T

    RequiredEntityData

    RequiredEntityData<T, I, C>: { [ K in keyof T as RequiredKeys<T, K, I> ]: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]> } & { [ K in keyof T as OptionalKeys<T, K, I> ]?: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]> | null }

    Type parameters

    • T
    • I = never
    • C: boolean = false

    Scalar

    Scalar: boolean | number | string | bigint | symbol | Date | RegExp | Uint8Array | { toHexString: any }

    ScalarRef

    ScalarRef<T>: ScalarReference<T>

    Alias for ScalarReference (see Ref).


    Type parameters

    • T

    Selected

    Selected<T, L, F>: { [ K in keyof T as IsPrefixed<T, K, L | F | AddEager<T>> ]: LoadedProp<NonNullable<T[K]>, Suffix<K, L, true>, Suffix<K, F, true>> | AddOptional<T[K]> } & { [ K in keyof T as FunctionKeys<T, K> ]: T[K] } & { [___selectedType]?: T }

    Type parameters

    • T
    • L: string = never
    • F: string = *

    Transaction

    Transaction<T>: T

    Type parameters

    • T = any

    TransactionEventType

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

    UmzugMigration

    UmzugMigration: { name: string; path?: string }

    Type declaration

    • name: string
    • optionalpath?: string

    UnboxArray

    UnboxArray<T>: T extends any[] ? ArrayElement<T> : T

    Type parameters

    • T

    Variables

    constARRAY_OPERATORS

    ARRAY_OPERATORS: string[] = ...

    constConfig

    Config: typeof Config = ...

    constEagerProps

    EagerProps: typeof EagerProps = ...

    constEntityManagerType

    EntityManagerType: typeof EntityManagerType = ...

    constEntityRepositoryType

    EntityRepositoryType: typeof EntityRepositoryType = ...

    constEventTypeMap

    EventTypeMap: Record<EventType, number> = ...

    constHiddenProps

    HiddenProps: typeof HiddenProps = ...

    constJSON_KEY_OPERATORS

    JSON_KEY_OPERATORS: string[] = ...

    constJsonProperty

    JsonProperty: typeof JsonProperty = ...

    constObjectBindingPattern

    ObjectBindingPattern: typeof ObjectBindingPattern = ...

    constOptionalProps

    OptionalProps: typeof OptionalProps = ...

    constPrimaryKeyProp

    PrimaryKeyProp: typeof PrimaryKeyProp = ...

    constSCALAR_TYPES

    SCALAR_TYPES: string[] = ...

    constt

    t: { array: typeof ArrayType; bigint: typeof BigIntType; blob: typeof BlobType; boolean: typeof BooleanType; character: typeof CharacterType; date: typeof DateType; datetime: typeof DateTimeType; decimal: typeof DecimalType; double: typeof DoubleType; enum: typeof EnumType; enumArray: typeof EnumArrayType; float: typeof FloatType; integer: typeof IntegerType; interval: typeof IntervalType; 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

    consttypes

    types: { array: typeof ArrayType; bigint: typeof BigIntType; blob: typeof BlobType; boolean: typeof BooleanType; character: typeof CharacterType; date: typeof DateType; datetime: typeof DateTimeType; decimal: typeof DecimalType; double: typeof DoubleType; enum: typeof EnumType; enumArray: typeof EnumArrayType; float: typeof FloatType; integer: typeof IntegerType; interval: typeof IntervalType; 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