Skip to main content
Version: Next

UnitOfWork

Index

Constructors

constructor

Methods

cancelOrphanRemoval

  • cancelOrphanRemoval(entity: Partial<any>, visited?: Set<Partial<any>>): void
  • Parameters

    • entity: Partial<any>
    • optionalvisited: Set<Partial<any>>

    Returns void

clear

  • clear(): void
  • Returns void

clearActionsQueue

  • clearActionsQueue(): void
  • Returns void

commit

  • commit(): Promise<void>
  • Returns Promise<void>

computeChangeSet

computeChangeSets

  • computeChangeSets(): void
  • Returns void

getById

  • getById(entityName: string, id: (T extends { [PrimaryKeyProp]?: PK } ? 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 { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T) | (T extends { [PrimaryKeyProp]?: PK } ? 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 { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T)[], schema?: string): undefined | T
  • 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.


    Parameters

    • entityName: string
    • id: (T extends { [PrimaryKeyProp]?: PK } ? 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 { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T) | (T extends { [PrimaryKeyProp]?: PK } ? 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 { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T)[]
    • optionalschema: string

    Returns undefined | T

getChangeSetPersister

getChangeSets

getCollectionUpdates

  • getCollectionUpdates(): Collection<Partial<any>, object>[]

getExtraUpdates

getIdentityMap

  • Returns map of all managed entities.


    Returns IdentityMap

getOriginalEntityData

  • getOriginalEntityData(entity: T): undefined | EntityData<T>
  • Returns stored snapshot of entity state that is used for change set computation.


    Parameters

    • entity: T

    Returns undefined | EntityData<T>

getOrphanRemoveStack

  • getOrphanRemoveStack(): Set<Partial<any>>
  • Returns Set<Partial<any>>

getPersistStack

  • getPersistStack(): Set<Partial<any>>
  • Returns Set<Partial<any>>

getRemoveStack

  • getRemoveStack(): Set<Partial<any>>
  • Returns Set<Partial<any>>

lock

  • Parameters

    Returns Promise<void>

merge

  • merge(entity: T, visited?: Set<Partial<any>>): void
  • Parameters

    • entity: T
    • optionalvisited: Set<Partial<any>>

    Returns void

persist

  • persist(entity: T, visited?: Set<Partial<any>>, options?: { cascade?: boolean; checkRemoveStack?: boolean }): void
  • Parameters

    • entity: T
    • optionalvisited: Set<Partial<any>>
    • options: { cascade?: boolean; checkRemoveStack?: boolean } = {}
      • optionalcascade: boolean
      • optionalcheckRemoveStack: boolean

    Returns void

recomputeSingleChangeSet

  • recomputeSingleChangeSet(entity: T): void
  • Parameters

    • entity: T

    Returns void

remove

  • remove(entity: T, visited?: Set<Partial<any>>, options?: { cascade?: boolean }): void
  • Parameters

    • entity: T
    • optionalvisited: Set<Partial<any>>
    • options: { cascade?: boolean } = {}
      • optionalcascade: boolean

    Returns void

scheduleExtraUpdate

scheduleOrphanRemoval

  • scheduleOrphanRemoval(entity?: Partial<any>, visited?: Set<Partial<any>>): void
  • Parameters

    • optionalentity: Partial<any>
    • optionalvisited: Set<Partial<any>>

    Returns void

shouldAutoFlush

tryGetById

  • tryGetById(entityName: string, where: FilterQuery<T>, schema?: string, strict?: boolean): null | T
  • Parameters

    • entityName: string
    • where: FilterQuery<T>
    • optionalschema: string
    • strict: boolean = true

    Returns null | T

unsetIdentity

  • unsetIdentity(entity: Partial<any>): void
  • Parameters

    • entity: Partial<any>

    Returns void