UnitOfWork
Index
Constructors
Methods
- cancelOrphanRemoval
- clear
- clearActionsQueue
- commit
- computeChangeSet
- computeChangeSets
- getById
- getByKey
- getChangeSetPersister
- getChangeSets
- getCollectionUpdates
- getExtraUpdates
- getIdentityMap
- getOriginalEntityData
- getOrphanRemoveStack
- getPersistStack
- getRemoveStack
- lock
- merge
- persist
- recomputeSingleChangeSet
- remove
- scheduleExtraUpdate
- scheduleOrphanRemoval
- shouldAutoFlush
- storeByKey
- tryGetById
- unsetIdentity
Constructors
constructor
Parameters
Returns UnitOfWork
Methods
cancelOrphanRemoval
Parameters
entity: Partial<any>
optionalvisited: Set<Partial<any>>
Returns void
clear
Returns void
clearActionsQueue
Returns void
commit
Returns Promise<void>
computeChangeSet
Parameters
entity: T
optionaltype: ChangeSetType
Returns void
computeChangeSets
Returns void
getById
Parameters
entityName: EntityName<T>
id: (T extends { [PrimaryKeyProp]?: PK } ? PK extends undefined ? Omit<T<T>, typeof PrimaryKeyProp> : PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T) | (T extends { [PrimaryKeyProp]?: PK } ? PK extends undefined ? Omit<T<T>, typeof PrimaryKeyProp> : PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T)[]
optionalschema: string
optionalconvertCustomTypes: boolean
Returns undefined | T
getByKey
Returns entity from the identity map by an alternate key (non-PK property).
Parameters
entityName: EntityName<T>
key: string
value: unknown
optionalschema: string
optionalconvertCustomTypes: boolean
If true, the value is in database format and will be converted to JS format for lookup. If false (default), the value is assumed to be in JS format already.
Returns undefined | T
getChangeSetPersister
Returns ChangeSetPersister
getChangeSets
Returns ChangeSet<Partial<any>>[]
getCollectionUpdates
Returns Collection<Partial<any>, object>[]
getExtraUpdates
Returns Set<[Partial<any>, string | string[], Reference<any> | Partial<any> | Collection<any, object> | Partial<any>[], undefined | ChangeSet<any>, ChangeSetType]>
getIdentityMap
Returns map of all managed entities.
Returns IdentityMap
getOriginalEntityData
Returns stored snapshot of entity state that is used for change set computation.
Parameters
entity: T
Returns undefined | EntityData<T>
getOrphanRemoveStack
Returns Set<Partial<any>>
getPersistStack
Returns Set<Partial<any>>
getRemoveStack
Returns Set<Partial<any>>
lock
Parameters
entity: T
options: LockOptions
Returns Promise<void>
merge
Parameters
entity: T
optionalvisited: Set<Partial<any>>
Returns void
persist
Parameters
entity: T
optionalvisited: Set<Partial<any>>
options: { cascade?: boolean; checkRemoveStack?: boolean } = {}
optionalcascade: boolean
optionalcheckRemoveStack: boolean
Returns void
recomputeSingleChangeSet
Parameters
entity: T
Returns void
remove
Parameters
entity: T
optionalvisited: Set<Partial<any>>
options: { cascade?: boolean } = {}
optionalcascade: boolean
Returns void
scheduleExtraUpdate
Parameters
changeSet: ChangeSet<T>
props: EntityProperty<T, any>[]
Returns void
scheduleOrphanRemoval
Parameters
optionalentity: Partial<any>
optionalvisited: Set<Partial<any>>
Returns void
shouldAutoFlush
Parameters
meta: EntityMetadata<T, EntityCtor<T>>
Returns boolean
storeByKey
Stores an entity in the identity map under an alternate key (non-PK property). Also sets the property value on the entity.
Parameters
entity: T
key: string
value: unknown
optionalschema: string
optionalconvertCustomTypes: boolean
If true, the value is in database format and will be converted to JS format. If false (default), the value is assumed to be in JS format already.
Returns void
tryGetById
Parameters
entityName: EntityName<T>
where: FilterQuery<T>
optionalschema: string
strict: boolean = true
Returns null | T
unsetIdentity
Parameters
entity: Partial<any>
Returns void
Returns entity from the identity map. For composite keys, you need to pass an array of PKs in the same order as they are defined in
meta.primaryKeys.