Version: 4.3

Class: EntityFactory

Hierarchy

  • EntityFactory

Constructors

constructor

+ new EntityFactory(unitOfWork: UnitOfWork, em: EntityManager): EntityFactory

Defined in packages/core/src/entity/EntityFactory.ts:22

Parameters:

NameType
unitOfWorkUnitOfWork
emEntityManager

Returns: EntityFactory

Properties

config

Private Readonly config: Configuration<IDatabaseDriver<Connection>> = this.em.config

Defined in packages/core/src/entity/EntityFactory.ts:19


driver

Private Readonly driver: IDatabaseDriver<Connection> = this.em.getDriver()

Defined in packages/core/src/entity/EntityFactory.ts:17


em

Private Readonly em: EntityManager

Defined in packages/core/src/entity/EntityFactory.ts:25


eventManager

Private Readonly eventManager: EventManager = this.em.getEventManager()

Defined in packages/core/src/entity/EntityFactory.ts:22


hydrator

Private Readonly hydrator: IHydrator = this.config.getHydrator(this.metadata)

Defined in packages/core/src/entity/EntityFactory.ts:21


metadata

Private Readonly metadata: MetadataStorage = this.em.getMetadata()

Defined in packages/core/src/entity/EntityFactory.ts:20


platform

Private Readonly platform: Platform = this.driver.getPlatform()

Defined in packages/core/src/entity/EntityFactory.ts:18


unitOfWork

Private Readonly unitOfWork: UnitOfWork

Defined in packages/core/src/entity/EntityFactory.ts:24

Methods

create

create<T, P>(entityName: EntityName<T>, data: EntityData<T>, options?: FactoryOptions): New<T, P>

Defined in packages/core/src/entity/EntityFactory.ts:27

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PPopulate<T>any

Parameters:

NameTypeDefault value
entityNameEntityName<T>-
dataEntityData<T>-
optionsFactoryOptions{}

Returns: New<T, P>


createEntity

PrivatecreateEntity<T>(data: EntityData<T>, meta: EntityMetadata<T>, options: FactoryOptions): T

Defined in packages/core/src/entity/EntityFactory.ts:87

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
dataEntityData<T>
metaEntityMetadata<T>
optionsFactoryOptions

Returns: T


createReference

createReference<T>(entityName: EntityName<T>, id: Primary<T> | Primary<T>[] | Record<string, Primary<T>>, options?: Pick<FactoryOptions, "merge" | "convertCustomTypes">): T

Defined in packages/core/src/entity/EntityFactory.ts:63

Type parameters:

Name
T

Parameters:

NameTypeDefault value
entityNameEntityName<T>-
idPrimary<T> | Primary<T>[] | Record<string, Primary<T>>-
optionsPick<FactoryOptions, "merge" | "convertCustomTypes">{}

Returns: T


denormalizePrimaryKey

PrivatedenormalizePrimaryKey<T>(data: EntityData<T>, primaryKey: string, prop: EntityProperty<T>): void

Defined in packages/core/src/entity/EntityFactory.ts:152

denormalize PK to value required by driver (e.g. ObjectId)

Type parameters:

Name
T

Parameters:

NameType
dataEntityData<T>
primaryKeystring
propEntityProperty<T>

Returns: void


extractConstructorParams

PrivateextractConstructorParams<T>(meta: EntityMetadata<T>, data: EntityData<T>): T[keyof T][]

Defined in packages/core/src/entity/EntityFactory.ts:170

returns parameters for entity constructor, creating references from plain ids

Type parameters:

Name
T

Parameters:

NameType
metaEntityMetadata<T>
dataEntityData<T>

Returns: T[keyof T][]


findEntity

PrivatefindEntity<T>(data: EntityData<T>, meta: EntityMetadata<T>, convertCustomTypes?: boolean): T | undefined

Defined in packages/core/src/entity/EntityFactory.ts:117

Type parameters:

Name
T

Parameters:

NameType
dataEntityData<T>
metaEntityMetadata<T>
convertCustomTypes?boolean

Returns: T | undefined


hydrate

Privatehydrate<T>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, options: FactoryOptions): void

Defined in packages/core/src/entity/EntityFactory.ts:109

Type parameters:

Name
T

Parameters:

NameType
entityT
metaEntityMetadata<T>
dataEntityData<T>
optionsFactoryOptions

Returns: void


processDiscriminatorColumn

PrivateprocessDiscriminatorColumn<T>(meta: EntityMetadata<T>, data: EntityData<T>): EntityMetadata<T>

Defined in packages/core/src/entity/EntityFactory.ts:131

Type parameters:

Name
T

Parameters:

NameType
metaEntityMetadata<T>
dataEntityData<T>

Returns: EntityMetadata<T>

Last updated on by Martin Adámek