Class MemoryQuery<T>

This a generic query abstraction which should supports most basics database interactions.

All query implementations should extend this since db agnostic consumers are probably coded against this interface via Database which uses this GenericQuery.

Type Parameters

Hierarchy

Constructors

Properties

_: (() => T)

Type declaration

    • (): T
    • Returns T

classSchema: ReflectionClass<any>
isMemory: boolean = true
lifts: ClassType<any>[] = []
model: DatabaseQueryModel<T, FilterQuery<T>, Sort<T, any>>
session: DatabaseSession<any>
onDeletePost: EventToken<QueryDatabaseDeleteEvent<any>> = ...
onDeletePre: EventToken<QueryDatabaseDeleteEvent<any>> = ...
onFetch: EventToken<QueryDatabaseEvent<any>> = ...
onPatchPost: EventToken<QueryDatabasePatchEvent<any>> = ...
onPatchPre: EventToken<QueryDatabasePatchEvent<any>> = ...

Methods

  • When fetching objects from the database, for each object will a snapshot be generated, on which change-detection happens. This behavior is not necessary when only fetching data and never modifying its objects (when for example returning data to the client directly). When this is the case, you can disable change-detection entirely for the returned objects. Note: Persisting/committing (database.persist(), session.commit) won't detect any changes when change-detection is disabled.

    Returns MemoryQuery<T>

  • Identity mapping is used to store all created entity instances in a pool. If a query fetches an already known entity instance, the old will be picked. This ensures object instances uniqueness and generally saves CPU circles.

    This disabled entity tracking, forcing always to create new entity instances.

    For queries created on the database object (database.query(T)), this is disabled per default. Only on sessions (const session = database.createSession(); session.query(T)) is the identity map enabled per default, and can be disabled with this method.

    Returns MemoryQuery<T>

  • Parameters

    • Optional singleKey: false

    Returns Promise<PrimaryKeyFields<T>[]>

  • Parameters

    • singleKey: true

    Returns Promise<PrimaryKeyType<T>[]>

  • Adds a inner join in the filter. Does NOT populate the reference with values. Accessing field in the entity (if not optional field) results in an error.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • field: K

    Returns MemoryQuery<T>

  • Adds a left join in the filter. Does NOT populate the reference with values. Accessing field in the entity (if not optional field) results in an error.

    Type Parameters

    • K extends string | number | symbol

    • ENTITY extends OrmEntity = FindEntity<T[K]>

    Parameters

    • field: K
    • type: "left" | "inner" = 'left'
    • populate: boolean = false

    Returns MemoryQuery<T>

  • Adds a left join in the filter. Does NOT populate the reference with values. Accessing field in the entity (if not optional field) results in an error. Returns JoinDatabaseQuery to further specify the join, which you need to .end()

    Type Parameters

    • K extends string | number | symbol

    • ENTITY extends OrmEntity = FindEntity<T[K]>

    Parameters

    • field: K

    Returns JoinDatabaseQuery<ENTITY, MemoryQuery<T>>

  • Type Parameters

    • Q extends Query<any, Q> & {
          _: (() => T);
      }

    • T extends any

    • B extends ClassType<Query<any>, B>

    Parameters

    • this: B
    • query: Q

    Returns Replace<InstanceType<B>, ReturnType<Q["_"]>>

Generated using TypeDoc