Skip to main content
Version: Next

UnitOfWork

Index

Constructors

constructor

Methods

cancelOrphanRemoval

  • cancelOrphanRemoval(entity, visited): 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

  • computeChangeSet<T>(entity, type): void

computeChangeSets

  • computeChangeSets(): void
  • Returns void

getById

  • getById<T>(entityName, id, schema, convertCustomTypes): 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: 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

  • getByKey<T>(entityName, key, value, schema, convertCustomTypes): undefined | T
  • 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

getChangeSets

getCollectionUpdates

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

getExtraUpdates

getIdentityMap

  • Returns map of all managed entities.


    Returns IdentityMap

getOriginalEntityData

  • getOriginalEntityData<T>(entity): 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

  • lock<T>(entity, options): Promise<void>
  • Parameters

    Returns Promise<void>

merge

  • merge<T>(entity, visited): void
  • Parameters

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

    Returns void

persist

  • persist<T>(entity, visited, options): void
  • Parameters

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

    Returns void

recomputeSingleChangeSet

  • recomputeSingleChangeSet<T>(entity): void
  • Parameters

    • entity: T

    Returns void

remove

  • remove<T>(entity, visited, options): void
  • Parameters

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

    Returns void

scheduleExtraUpdate

  • scheduleExtraUpdate<T>(changeSet, props): void

scheduleOrphanRemoval

  • scheduleOrphanRemoval(entity, visited): void
  • Parameters

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

    Returns void

shouldAutoFlush

  • shouldAutoFlush<T>(meta): boolean

storeByKey

  • storeByKey<T>(entity, key, value, schema, convertCustomTypes): void
  • 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

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

    Returns null | T

unsetIdentity

  • unsetIdentity(entity): void
  • Parameters

    • entity: Partial<any>

    Returns void