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 Parameter | Description |
---|---|
OM extends BaseObjectMap | - |
T extends PlainObject | The 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
new ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>(): ReactiveQueryBuilderIntrospector<OM, T, PK, R, H>;
Returns
ReactiveQueryBuilderIntrospector
<OM
, T
, PK
, R
, H
>
Accessors
abortController
Get Signature
get abortController(): AbortController;
Gets the abort controller.
Throws
If accessed before initialization
Returns
AbortController
addCleanupCallback
Get Signature
get addCleanupCallback(): (cb: () => Promise<void>) => void;
Gets the cleanup callback registrar.
Throws
If accessed before initialization
Returns
(cb: () => Promise<void>): void;
Parameters
Parameter | Type |
---|---|
cb | () => Promise <void > |
Returns
void
clauses
Get Signature
get clauses(): ReactiveQueryBuilderClause[];
Gets the current query builder clauses.
Throws
If accessed before initialization
Returns
ReactiveQueryBuilderClause
[]
ctor
Get Signature
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
get logBus(): TypedEventEmitter<LogBusEventMap>;
Gets the log bus event emitter.
Throws
If accessed before initialization
Returns
TypedEventEmitter
<LogBusEventMap
>
primaryKey
Get Signature
get primaryKey(): PK;
Gets the primary key.
Throws
If accessed before initialization
Returns
PK
relatable
Get Signature
get relatable(): StringKeyOf<R>[];
Gets the available relationship names.
Throws
If accessed before initialization
Returns
StringKeyOf
<R
>[]
relations
Get Signature
get relations(): Set<StringKeyOf<R>>;
Gets the set of active relations.
Throws
If accessed before initialization
Returns
Set
<StringKeyOf
<R
>>
table
Get Signature
get table(): EntityTable<T>;
Gets the database table.
Throws
If accessed before initialization
Returns
EntityTable
<T
>
whereConditions
Get Signature
get whereConditions(): WhereCondition<T>[];
Gets the current query builder where conditions.
Throws
If accessed before initialization
Returns
WhereCondition
<T
>[]
Methods
$init()
$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
Parameter | Type | Description |
---|---|---|
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 >) => void | Function to access the cleanup callback registrar |
abortController | () => AbortController | Function to access the abort controller |
log | <K >(level : Key <K , LogBusEventMap >, ...args : any []) => void | Function 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()
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()
getReturnable(record: ReactiveModel<T, PK, R>): Promise<ReactiveModel<T, PK, R>>;
Gets a single query result.
Parameters
Parameter | Type |
---|---|
record | ReactiveModel <T , PK , R > |
Returns
Promise
<ReactiveModel
<T
, PK
, R
>>
A promise that resolves to a model instance
Throws
If accessed before initialization
getReturnableArray()
getReturnableArray(records: ReactiveModel<T, PK, R>[]): Promise<ReactiveModel<T, PK, R>[]>;
Gets an array of query results.
Parameters
Parameter | Type |
---|---|
records | ReactiveModel <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()
log<K>(level: Key<K, LogBusEventMap>, ...args: any[]): void;
Logs a message with the specified level.
Type Parameters
Type Parameter |
---|
K |
Parameters
Parameter | Type | Description |
---|---|---|
level | Key <K , LogBusEventMap > | The log level |
...args | any [] | Arguments to log |
Returns
void
Throws
If accessed before initialization