Skip to content

Class: ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>

A testing utility class that provides introspection capabilities for ReactiveQueryBuilder. This class allows access to private members of ReactiveQueryBuilder for testing purposes.

Type Parameters

Type ParameterDescription
OM extends BaseObjectMap-
T extends PlainObjectThe type of the model being queried
PK extends StringKeyOf<T>The type of the primary key of the model
R extends Record<string, RelationshipConfiguration>The type of the relationship configurations
H extends Required<ReactiveDatabaseOptions<any>["hooks"]>-

Constructors

Constructor

ts
new ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>(): ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>;

Returns

ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>

Accessors

abortController

Get Signature

ts
get abortController(): AbortController;

Gets the abort controller.

Throws

If accessed before initialization

Returns

AbortController


addCleanupCallback

Get Signature

ts
get addCleanupCallback(): (cb: () => Promise<void>) => void;

Gets the cleanup callback registrar.

Throws

If accessed before initialization

Returns
ts
(cb: () => Promise<void>): void;
Parameters
ParameterType
cb() => Promise<void>
Returns

void


clauses

Get Signature

ts
get clauses(): ReactiveQueryBuilderClause[];

Gets the current query builder clauses.

Throws

If accessed before initialization

Returns

ReactiveQueryBuilderClause[]


ctor

Get Signature

ts
get ctor(): ReactiveModelConstructor<OM, T, PK, R, H>;

Gets the model constructor.

Throws

If accessed before initialization

Returns

ReactiveModelConstructor<OM, T, PK, R, H>


logBus

Get Signature

ts
get logBus(): TypedEventEmitter<LogBusEventMap>;

Gets the log bus event emitter.

Throws

If accessed before initialization

Returns

TypedEventEmitter<LogBusEventMap>


primaryKey

Get Signature

ts
get primaryKey(): PK;

Gets the primary key.

Throws

If accessed before initialization

Returns

PK


relatable

Get Signature

ts
get relatable(): StringKeyOf<R>[];

Gets the available relationship names.

Throws

If accessed before initialization

Returns

StringKeyOf<R>[]


relations

Get Signature

ts
get relations(): Set<StringKeyOf<R>>;

Gets the set of active relations.

Throws

If accessed before initialization

Returns

Set<StringKeyOf<R>>


table

Get Signature

ts
get table(): EntityTable<T>;

Gets the database table.

Throws

If accessed before initialization

Returns

EntityTable<T>


whereConditions

Get Signature

ts
get whereConditions(): WhereCondition<T>[];

Gets the current query builder where conditions.

Throws

If accessed before initialization

Returns

WhereCondition<T>[]

Methods

$init()

ts
$init(
   clauses: () => ReactiveQueryBuilderClause[],
   whereConditions: () => WhereCondition<T>[],
   ctor: () => ReactiveModelConstructor<OM, T, PK, R, H>,
   relatable: () => StringKeyOf<R>[],
   table: () => EntityTable<T>,
   primaryKey: () => PK,
   relations: () => Set<StringKeyOf<R>>,
   logBus: () => TypedEventEmitter<LogBusEventMap>,
   addCleanupCallback: () => (cb: () => Promise<void>) => void,
   abortController: () => AbortController,
   log: <K>(level: Key<K, LogBusEventMap>, ...args: any[]) => void,
   execute: () => Promise<
  | undefined
  | number
  | ReactiveModel<T, PK, R>
  | ReactiveModel<T, PK, R>[]>,
   getReturnableArray: (records: ReactiveModel<T, PK, R>[]) => Promise<ReactiveModel<T, PK, R>[]>,
   getReturnable: (record: ReactiveModel<T, PK, R>) => Promise<ReactiveModel<T, PK, R>>): void;

Initializes the introspector with accessors to private members of ReactiveQueryBuilder. This method can only be called once - subsequent calls will throw an error.

Parameters

ParameterTypeDescription
clauses() => ReactiveQueryBuilderClause[]Function to access query builder clauses
whereConditions() => WhereCondition<T>[]-
ctor() => ReactiveModelConstructor<OM, T, PK, R, H>Function to access the model constructor
relatable() => StringKeyOf<R>[]Function to access available relationship names
table() => EntityTable<T>Function to access the database table
primaryKey() => PK-
relations() => Set<StringKeyOf<R>>Function to access active relations
logBus() => TypedEventEmitter<LogBusEventMap>Function to access the log bus
addCleanupCallback() => (cb: () => Promise<void>) => voidFunction to access the cleanup callback registrar
abortController() => AbortControllerFunction to access the abort controller
log<K>(level: Key<K, LogBusEventMap>, ...args: any[]) => voidFunction to access the logging function
execute() => Promise< | undefined | number | ReactiveModel<T, PK, R> | ReactiveModel<T, PK, R>[]>Function to access the query execution function
getReturnableArray(records: ReactiveModel<T, PK, R>[]) => Promise<ReactiveModel<T, PK, R>[]>Function to access the array result getter
getReturnable(record: ReactiveModel<T, PK, R>) => Promise<ReactiveModel<T, PK, R>>Function to access the single result getter

Returns

void

Throws

If attempting to reinitialize any accessor


execute()

ts
execute(): Promise<
  | undefined
  | number
  | ReactiveModel<T, PK, R>
| ReactiveModel<T, PK, R>[]>;

Executes the query.

Returns

Promise< | undefined | number | ReactiveModel<T, PK, R> | ReactiveModel<T, PK, R>[]>

A promise that resolves when the query is executed

Throws

If accessed before initialization


getReturnable()

ts
getReturnable(record: ReactiveModel<T, PK, R>): Promise<ReactiveModel<T, PK, R>>;

Gets a single query result.

Parameters

ParameterType
recordReactiveModel<T, PK, R>

Returns

Promise<ReactiveModel<T, PK, R>>

A promise that resolves to a model instance

Throws

If accessed before initialization


getReturnableArray()

ts
getReturnableArray(records: ReactiveModel<T, PK, R>[]): Promise<ReactiveModel<T, PK, R>[]>;

Gets an array of query results.

Parameters

ParameterType
recordsReactiveModel<T, PK, R>[]

Returns

Promise<ReactiveModel<T, PK, R>[]>

A promise that resolves to an array of model instances

Throws

If accessed before initialization


log()

ts
log<K>(level: Key<K, LogBusEventMap>, ...args: any[]): void;

Logs a message with the specified level.

Type Parameters

Type Parameter
K

Parameters

ParameterTypeDescription
levelKey<K, LogBusEventMap>The log level
...argsany[]Arguments to log

Returns

void

Throws

If accessed before initialization