Skip to main content
Version: Next

MetadataDiscoveryOptions

Configuration options for metadata discovery.

@see

Index

Properties

optionalafterDiscovered

afterDiscovered?: (storage, platform) => MaybePromise<void>

Hook called after all entities are discovered. Can be used to access and modify all metadata at once.


Type declaration

optionalcheckDuplicateFieldNames

checkDuplicateFieldNames?: boolean = true

Check for duplicate field names and throw an error if found.

optionalcheckDuplicateTableNames

checkDuplicateTableNames?: boolean = true

Check for duplicate table names and throw an error if found.

optionalcheckNonPersistentCompositeProps

checkNonPersistentCompositeProps?: boolean = true

Check for composite primary keys marked as persist: false and throw an error if found.

optionalgetMappedType

getMappedType?: (type, platform) => undefined | Type<unknown, unknown>

Custom callback to override default type mapping. Allows customizing how property types are mapped to database column types.

@example
getMappedType(type, platform) {
if (type === 'string') {
return Type.getType(TextType);
}
return platform.getDefaultMappedType(type);
}

Type declaration

    • (type, platform): undefined | Type<unknown, unknown>
    • Parameters

      Returns undefined | Type<unknown, unknown>

optionalinferDefaultValues

inferDefaultValues?: boolean = true

Infer default values from property initializers when possible (if the constructor can be invoked without parameters).

optionalonMetadata

onMetadata?: (meta, platform) => MaybePromise<void>

Hook called for each entity metadata during discovery. Can be used to modify metadata dynamically before defaults are filled in. The hook can be async when using MikroORM.init().


Type declaration

optionaltsConfigPath

tsConfigPath?: string

Path to the TypeScript configuration file for ts-morph metadata provider.

optionalwarnWhenNoEntities

warnWhenNoEntities?: boolean = true

Throw an error when no entities are discovered.