Skip to main content
Version: 4.5

Class: EntityComparator#

core.EntityComparator

Constructors#

constructor#

+ new EntityComparator(metadata: IMetadataStorage, platform: Platform): EntityComparator

Parameters:#

NameType
metadataIMetadataStorage
platformPlatform

Returns: EntityComparator

Defined in: packages/core/src/utils/EntityComparator.ts:19

Properties#

comparators#

Private Readonly comparators: Map<string, Comparator<any>>

Defined in: packages/core/src/utils/EntityComparator.ts:15


mappers#

Private Readonly mappers: Map<string, ResultMapper<any>>

Defined in: packages/core/src/utils/EntityComparator.ts:16


pkGetters#

Private Readonly pkGetters: Map<string, PkGetter<any>>

Defined in: packages/core/src/utils/EntityComparator.ts:18


pkSerializers#

Private Readonly pkSerializers: Map<string, PkSerializer<any>>

Defined in: packages/core/src/utils/EntityComparator.ts:19


snapshotGenerators#

Private Readonly snapshotGenerators: Map<string, SnapshotGenerator<any>>

Defined in: packages/core/src/utils/EntityComparator.ts:17

Methods#

diffEntities#

diffEntities<T>(entityName: string, a: T, b: T): EntityData<T>

Computes difference between two entities.

Type parameters:#

NameType
TEntityData<T>

Parameters:#

NameType
entityNamestring
aT
bT

Returns: EntityData<T>

Defined in: packages/core/src/utils/EntityComparator.ts:27


getEmbeddedArrayPropertySnapshot#

PrivategetEmbeddedArrayPropertySnapshot<T>(meta: EntityMetadata<T>, prop: EntityProperty<T>, context: Map<string, any>, level: number, path?: string[], dataKey?: string, object?: boolean, serialize?: boolean): string

Type parameters:#

Name
T

Parameters:#

NameType
metaEntityMetadata<T>
propEntityProperty<T>
contextMap<string, any>
levelnumber
pathstring[]
dataKey?string
object?boolean
serialize?boolean

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:225


getEmbeddedPropertySnapshot#

PrivategetEmbeddedPropertySnapshot<T>(meta: EntityMetadata<T>, prop: EntityProperty<T>, context: Map<string, any>, level: number, path?: string[], dataKey?: string, object?: undefined | boolean): string

Type parameters:#

Name
T

Parameters:#

NameType
metaEntityMetadata<T>
propEntityProperty<T>
contextMap<string, any>
levelnumber
pathstring[]
dataKey?string
objectundefined | boolean

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:259


getEntityComparator#

getEntityComparator<T>(entityName: string): Comparator<T>

internal Highly performance-sensitive method.

Type parameters:#

Name
T

Parameters:#

NameType
entityNamestring

Returns: Comparator<T>

Defined in: packages/core/src/utils/EntityComparator.ts:355


getGenericComparator#

PrivategetGenericComparator(prop: string, cond: string): string

Parameters:#

NameType
propstring
condstring

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:381


getPkGetter#

getPkGetter<T>(meta: EntityMetadata<T>): any

internal Highly performance-sensitive method.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
metaEntityMetadata<T>

Returns: any

Defined in: packages/core/src/utils/EntityComparator.ts:52


getPkSerializer#

getPkSerializer<T>(meta: EntityMetadata<T>): any

internal Highly performance-sensitive method.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
metaEntityMetadata<T>

Returns: any

Defined in: packages/core/src/utils/EntityComparator.ts:94


getPropertyComparator#

PrivategetPropertyComparator<T>(prop: EntityProperty<T>): string

Type parameters:#

Name
T

Parameters:#

NameType
propEntityProperty<T>

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:390


getPropertyCondition#

PrivategetPropertyCondition<T>(prop: EntityProperty<T>): string

Type parameters:#

Name
T

Parameters:#

NameType
propEntityProperty<T>

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:209


getPropertySnapshot#

PrivategetPropertySnapshot<T>(meta: EntityMetadata<T>, prop: EntityProperty<T>, context: Map<string, any>, dataKey?: string, path?: string[], level?: number, object?: boolean): string

Type parameters:#

Name
T

Parameters:#

NameTypeDefault value
metaEntityMetadata<T>-
propEntityProperty<T>-
contextMap<string, any>-
dataKey?string-
path?string[]-
levelnumber1
object?boolean-

Returns: string

Defined in: packages/core/src/utils/EntityComparator.ts:301


getResultMapper#

getResultMapper<T>(entityName: string): ResultMapper<T>

internal Highly performance-sensitive method.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring

Returns: ResultMapper<T>

Defined in: packages/core/src/utils/EntityComparator.ts:172


getSnapshotGenerator#

getSnapshotGenerator<T>(entityName: string): SnapshotGenerator<T>

internal Highly performance-sensitive method.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring

Returns: SnapshotGenerator<T>

Defined in: packages/core/src/utils/EntityComparator.ts:135


mapResult#

mapResult<T>(entityName: string, result: EntityData<T>): null | EntityData<T>

Maps database columns to properties.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
resultEntityData<T>

Returns: null | EntityData<T>

Defined in: packages/core/src/utils/EntityComparator.ts:44


prepareEntity#

prepareEntity<T>(entity: T): EntityData<T>

Removes ORM specific code from entities and prepares it for serializing. Used before change set computation. References will be mapped to primary keys, collections to arrays of primary keys.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityT

Returns: EntityData<T>

Defined in: packages/core/src/utils/EntityComparator.ts:36


shouldSerialize#

PrivateshouldSerialize(prop: EntityProperty<any>, dataKey: string): boolean

we need to serialize only object embeddables, and only the top level ones, so root object embeddable properties and first child nested object embeddables with inlined parent

Parameters:#

NameType
propEntityProperty<any>
dataKeystring

Returns: boolean

Defined in: packages/core/src/utils/EntityComparator.ts:251


isComparable#

StaticisComparable<T>(prop: EntityProperty<T>, root: EntityMetadata<any>): boolean

perf: used to generate list of comparable properties during discovery, so we speed up the runtime comparison

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
propEntityProperty<T>
rootEntityMetadata<any>

Returns: boolean

Defined in: packages/core/src/utils/EntityComparator.ts:434

Last updated on by Renovate Bot