Class: AsyncQueryable<T, E>
Fluent query operators used when constructing queries.
A query can be created by accessing entity sets exposed by the Verse.from property.
Example
const customer =
await db.from.customers
.where(c => c.name === "ACME Corp.")
.single();
Extended by
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of the entity being queried. |
E extends Entities | - |
Implements
Methods
all()
all<
P,A>(predicate:P, ...args:A):Promise<boolean>
Determines whether all elements of a sequence satisfy a condition.
Type Parameters
| Type Parameter |
|---|
P extends (...args: readonly unknown[]) => boolean | (obj: T, ...args: A) => boolean | (...args: readonly [T, unknown]) => boolean & (obj: T, ...args: A) => boolean |
A extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | P | A function to test each element for a condition. |
...args | A | Additional arguments to be passed to the predicate. |
Returns
Promise<boolean>
A promise that resolves with true if all elements in the sequence satisfy the condition, otherwise false.
Defined in
packages/verse-core/src/query/queryable.ts:721
any()
any()
any():
Promise<boolean>
Determines whether a sequence contains any elements.
Returns
Promise<boolean>
A promise that resolves with true if the sequence contains any elements, otherwise false.
Defined in
packages/verse-core/src/query/queryable.ts:694
any(predicate, args)
any<
P,A>(predicate:P, ...args:A):Promise<boolean>
Determines whether any element of a sequence satisfies a condition.
Type Parameters
| Type Parameter |
|---|
P extends (...args: readonly unknown[]) => boolean | (obj: T, ...args: A) => boolean | (...args: readonly [T, unknown]) => boolean & (obj: T, ...args: A) => boolean |
A extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | P | A function to test each element for a condition. |
...args | A | Additional arguments to be passed to the predicate. |
Returns
Promise<boolean>
A promise that resolves with true if any elements in the sequence satisfy the condition, otherwise false.
Defined in
packages/verse-core/src/query/queryable.ts:703
array()
array():
AsyncQueryable<T[],E>
Aggregates the elements of the sequence into an array.
Returns
AsyncQueryable<T[], E>
The queryable result of the array operation.
Defined in
packages/verse-core/src/query/queryable.ts:891
avg()
avg(
expr?:TextendsJoinResult<K> ? (...args: readonly [K]) =>number: (obj:T) =>number):Promise<number>
Returns the average value of the specified numerical expression for the sequence.
Parameters
| Parameter | Type | Description |
|---|---|---|
expr? | T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => number | The numerical expression to be evaluated. |
Returns
Promise<number>
A promise that resolves with the average value of the specified numerical expression for the sequence.
Defined in
packages/verse-core/src/query/queryable.ts:881
count()
count():
Promise<number>
Returns the number of elements in the sequence.
Returns
Promise<number>
A promise that resolves with the number of elements in the sequence.
Defined in
packages/verse-core/src/query/queryable.ts:837
distinct()
distinct():
AsyncQueryable<T,E>
Removes duplicate elements from the sequence.
Returns
AsyncQueryable<T, E>
The queryable result of the distinct operation.
Defined in
packages/verse-core/src/query/queryable.ts:537
execute()
protectedexecute(cache?:QueryCache):Promise<undefined> |AsyncSequenceImpl<any>
Parameters
| Parameter | Type |
|---|---|
cache? | QueryCache |
Returns
Promise<undefined> | AsyncSequenceImpl<any>
Defined in
packages/verse-core/src/query/queryable.ts:969
first()
first()
first():
Promise<T>
Returns the first element of a sequence.
Returns
Promise<T>
A promise that resolves with the first element in the sequence.
Throws
Error, if no such element is found.
Defined in
packages/verse-core/src/query/queryable.ts:733
first(predicate, args)
first<
P,A>(predicate?:P, ...args?:A):Promise<T>
Returns the first element of a sequence that satisfies a specified condition.
Type Parameters
| Type Parameter |
|---|
P extends (...args: readonly unknown[]) => boolean | (obj: T, ...args: A) => boolean | (...args: readonly [T, unknown]) => boolean & (obj: T, ...args: A) => boolean |
A extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate? | P | A function to test each element for a condition. |
...args? | A | Additional arguments to be passed to the predicate. |
Returns
Promise<T>
A promise that resolves with the first element in the sequence that satisfies the condition.
Throws
Error, if no such element is found.
Defined in
packages/verse-core/src/query/queryable.ts:743
groupBy()
groupBy(key)
groupBy<
K>(key:K):AsyncQueryable<{items:T[];key:ReturnType<K>; },E>
Groups the elements of a sequence according to a specified key selector function.
Type Parameters
| Type Parameter |
|---|
K extends (obj: T) => unknown | (...args: readonly unknown[]) => unknown |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | K | A function to extract the key for each element. |
Returns
AsyncQueryable<{items: T[];key: ReturnType<K>; }, E>
The result of the groupBy operation.
items
items:
T[]
key
key:
ReturnType<K>
Defined in
packages/verse-core/src/query/queryable.ts:636
groupBy(key, result)
groupBy<
K,R>(key:K,result: (param:Grouping<ReturnType<K>,T>) =>R):AsyncQueryable<R,E>
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group.
Type Parameters
| Type Parameter |
|---|
K extends (...args: readonly unknown[]) => unknown | (obj: T) => unknown |
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | K | A function to extract the key for each element. |
result | (param: Grouping<ReturnType<K>, T>) => R | A function to create a result value from each group. |
Returns
AsyncQueryable<R, E>
The queryable result of the groupBy operation.
Defined in
packages/verse-core/src/query/queryable.ts:648
join()
join<
S,C>(entityOrQuery:Newable<S> |AsyncQueryable<S,E>,condition:C):AsyncQueryable<JoinResult<Parameters<C>>,E>
Joins the sequence with another sequence based on a condition.
Type Parameters
| Type Parameter |
|---|
S |
C extends (left: T, right: S) => boolean | (...args: readonly [unknown, S]) => boolean |
Parameters
| Parameter | Type | Description |
|---|---|---|
entityOrQuery | Newable<S> | AsyncQueryable<S, E> | The entity or query to join with. |
condition | C | The join condition. |
Returns
AsyncQueryable<JoinResult<Parameters<C>>, E>
The queryable result of the join operation.
Defined in
packages/verse-core/src/query/queryable.ts:550
leftJoin()
leftJoin<
S,C>(entityOrQuery:Newable<S> |AsyncQueryable<S,E>,condition:C):AsyncQueryable<JoinResult<Parameters<C>>,E>
Left joins the sequence with another sequence based on a condition.
Type Parameters
| Type Parameter |
|---|
S |
C extends (left: T, right: S) => boolean | (...args: readonly [unknown, S]) => boolean |
Parameters
| Parameter | Type | Description |
|---|---|---|
entityOrQuery | Newable<S> | AsyncQueryable<S, E> | The entity or query to join with. |
condition | C | The join condition. |
Returns
AsyncQueryable<JoinResult<Parameters<C>>, E>
The queryable result of the join operation.
Defined in
packages/verse-core/src/query/queryable.ts:571
limit()
limit(
limit:number):AsyncQueryable<T,E>
Returns a specified number of contiguous elements from the start of a sequence.
Parameters
| Parameter | Type | Description |
|---|---|---|
limit | number | The number of elements to return. |
Returns
AsyncQueryable<T, E>
The queryable result of the limit operation.