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

  • Type parameters

    • T: object

    Parameters

    Returns void

computeChangeSets

  • computeChangeSets(): void
  • Returns void

getById

  • getById<T>(entityName: string, id: (T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends keyof T[] ? ReadonlyPrimary<PrimaryPropToType<T, 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 ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends keyof T[] ? ReadonlyPrimary<PrimaryPropToType<T, 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.


    Type parameters

    • T: object

    Parameters

    • entityName: string
    • id: (T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends keyof T[] ? ReadonlyPrimary<PrimaryPropToType<T, 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 ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends keyof T[] ? ReadonlyPrimary<PrimaryPropToType<T, 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

  • getExtraUpdates(): Set<[Partial<any>, string | string[], Reference<any> | Partial<any> | Collection<any, object> | Partial<any>[], undefined | ChangeSet<any>]>
  • Returns Set<[Partial<any>, string | string[], Reference<any> | Partial<any> | Collection<any, object> | Partial<any>[], undefined | ChangeSet<any>]>

getIdentityMap

  • Returns map of all managed entities.


    Returns IdentityMap

getOriginalEntityData

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


    Type parameters

    • T: object

    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

  • lock<T>(entity: T, options: LockOptions): Promise<void>
  • Type parameters

    • T: object

    Parameters

    Returns Promise<void>

merge

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

    • T: object

    Parameters

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

    Returns void

persist

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

    • T: object

    Parameters

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

    Returns void

recomputeSingleChangeSet

  • recomputeSingleChangeSet<T>(entity: T): void
  • Type parameters

    • T: object

    Parameters

    • entity: T

    Returns void

remove

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

    • T: object

    Parameters

    • entity: T
    • optionalvisited: Set<Partial<any>>
    • options: { cascade?: 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

  • Type parameters

    • T: object

    Parameters

    Returns boolean

tryGetById

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

    • T: object

    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