Class: AsyncQueryableRoot<T, E>
Fluent query operators that must appear at the root of a query expression.
Extends
AsyncQueryable
<T
,E
>
Type parameters
Type parameter | Description |
---|---|
T | The type of the entity being queried. |
E extends Entities | - |
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
.
Inherited from
Source
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
.
Inherited from
Source
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 (obj : T , ...args : A ) => boolean | (...args : readonly [T , unknown ]) => boolean & (obj : T , ...args : A ) => boolean | (...args : readonly unknown []) => 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
.
Inherited from
Source
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.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:891
avg()
avg(
expr
?:T
extendsJoinResult
<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.
Inherited from
Source
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.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:837
distinct()
distinct():
AsyncQueryableRoot
<T
,E
>
Removes duplicate elements from the sequence.
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the distinct operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:537
execute()
protected
execute(cache
?:QueryCache
):Promise ↗️
<undefined
> |AsyncSequenceImpl
<any
>
Parameters
Parameter | Type |
---|---|
cache ? | QueryCache |
Returns
Promise ↗️
<undefined
> | AsyncSequenceImpl
<any
>
Inherited from
Source
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.
Inherited from
Throws
Error, if no such element is found.
Source
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.
Inherited from
Throws
Error, if no such element is found.
Source
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
>
Inherited from
Source
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.
Inherited from
Source
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.
Inherited from
Source
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.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:571
limit()
limit(
limit
:number
):AsyncQueryableRoot
<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
AsyncQueryableRoot
<T
, E
>
The queryable result of the limit operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:671
max()
max(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):Promise ↗️
<number
>
Returns the maximum 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 maximum value of the specified numerical expression for the sequence.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:859
maybeFirst()
maybeFirst()
maybeFirst():
Promise ↗️
<undefined
|T
>
Returns the first element of a sequence, or undefined
if no such element is found.
Returns
Promise ↗️
<undefined
| T
>
A promise that resolves with the first element in the sequence,
or undefined
if no such element is found.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:757
maybeFirst(predicate, args)
maybeFirst<
P
,A
>(predicate
?:P
, ...args
?:A
):Promise ↗️
<undefined
|T
>
Returns the first element of a sequence that satisfies a specified condition, or undefined
if no such element is found.
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 ↗️
<undefined
| T
>
A promise that resolves with the first element in the sequence that satisfies the condition,
or undefined
if no such element is found.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:768
maybeSingle()
maybeSingle()
maybeSingle():
Promise ↗️
<undefined
|T
>
Returns the only element of a sequence, or undefined
if no such element is found.
Returns
Promise ↗️
<undefined
| T
>
A promise that resolves with the only element in the sequence, or undefined
if no such element is found.
Inherited from
Throws
Error, if multiple elements satisfy the condition.
Source
packages/verse-core/src/query/queryable.ts:810
maybeSingle(predicate, args)
maybeSingle<
P
,A
>(predicate
?:P
, ...args
?:A
):Promise ↗️
<undefined
|T
>
Returns the only element of a sequence that satisfies a specified condition, or undefined
if no such element is found.
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 ↗️
<undefined
| T
>
A promise that resolves with the only element in the sequence that satisfies the condition, or undefined
if no such element is found.
Inherited from
Throws
Error, if multiple elements satisfy the condition.
Source
packages/verse-core/src/query/queryable.ts:821
min()
min(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):Promise ↗️
<number
>
Returns the minimum 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 minimum value of the specified numerical expression for the sequence.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:848
offset()
offset(
offset
:number
):AsyncQueryableRoot
<T
,E
>
Skips a specified number of elements in a sequence and then returns the remaining elements.
Parameters
Parameter | Type | Description |
---|---|---|
offset | number | The number of elements to skip. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the offset operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:683
options()
options(
options
:QueryOptions
):AsyncQueryableRoot
<T
,E
>
Set query options that affect the behaviour of the query.
Parameters
Parameter | Type | Description |
---|---|---|
options | QueryOptions | The query options. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable with the specified options applied.
Example
const q =
db.from.albums.options({ disabledConditions: ["soft delete"] });
Source
packages/verse-core/src/query/queryable.ts:1018
orderBy()
orderBy<
E
,A
>(expr
:E
, ...args
:A
):AsyncQueryableRoot
<T
,E
>
Sorts the elements of a sequence in ascending order.
Type parameters
Type parameter |
---|
E extends (obj : T , ...args : A ) => unknown | (...args : readonly [T , unknown ]) => unknown & (obj : T , ...args : A ) => unknown | (...args : readonly unknown []) => unknown |
A extends unknown [] |
Parameters
Parameter | Type | Description |
---|---|---|
expr | E | A function to extract a sort key from an element. |
...args | A | Additional arguments to be passed to the expression. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the orderBy operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:605
orderByDesc()
orderByDesc<
E
,A
>(expr
:E
, ...args
:A
):AsyncQueryableRoot
<T
,E
>
Sorts the elements of a sequence in descending order.
Type parameters
Type parameter |
---|
E extends (...args : readonly unknown []) => unknown | (obj : T , ...args : A ) => unknown | (...args : readonly [T , unknown ]) => unknown & (obj : T , ...args : A ) => unknown |
A extends unknown [] |
Parameters
Parameter | Type | Description |
---|---|---|
expr | E | A function to extract a sort key from an element. |
...args | A | Additional arguments to be passed to the expression. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the orderByDesc operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:621
select()
select<
P
,A
>(projector
:P
, ...args
:A
):AsyncQueryable
<ReturnType ↗️
<P
>,E
>
Projects each element of a sequence into a new form.
Type parameters
Type parameter |
---|
P extends (obj : T , ...args : readonly [A , From <E >]) => unknown | (...args : readonly [unknown , A , From <E >]) => unknown |
A extends unknown [] |
Parameters
Parameter | Type | Description |
---|---|---|
projector | P | A function that transforms the input element. |
...args | A | Additional arguments to be passed to the projector. |
Returns
AsyncQueryable
<ReturnType ↗️
<P
>, E
>
The queryable result of the select operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:511
single()
single()
single():
Promise ↗️
<T
>
Returns the only element of a sequence.
Returns
Promise ↗️
<T
>
A promise that resolves with the only element in the sequence.
Inherited from
Throws
Error, if no such element is found, or there are multiple elements in the sequence.
Source
packages/verse-core/src/query/queryable.ts:785
single(predicate, args)
single<
P
,A
>(predicate
?:P
, ...args
?:A
):Promise ↗️
<T
>
Returns the only 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 only element in the sequence that satisfies the condition.
Inherited from
Throws
Error, if no such element is found, or multiple elements satisfy the condition.
Source
packages/verse-core/src/query/queryable.ts:795
sql()
sql(
strings
:TemplateStringsArray
, ...values
: readonlyany
[]):AsyncQueryableRoot
<T
,E
>
Inject a raw SQL query using tagged template literals. The returned queryable may be further composed with additional query operators.
Parameters
Parameter | Type | Description |
---|---|---|
strings | TemplateStringsArray | The SQL query template string. |
...values | readonly any [] | The values to be inserted into the query. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the injected SQL query.
Example
const id = 1;
const album =
db.from.albums
.sql`select * from "Album" where "AlbumId" = ${id}`
.single();
Source
packages/verse-core/src/query/queryable.ts:1002
sum()
sum(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):Promise ↗️
<number
>
Returns the sum 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 sum of the specified numerical expression for the sequence.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:870
toArray()
toArray():
Promise ↗️
<T
[]>
Buffers the sequence into an array of type T.
Returns
Promise ↗️
<T
[]>
A promise that resolves with an array of type T.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:902
where()
where<
P
,A
>(predicate
:P
, ...args
:A
):AsyncQueryableRoot
<T
,E
>
Filters a sequence of values based on a predicate.
Type parameters
Type parameter |
---|
P extends (obj : T , ...args : readonly [A , From <E >]) => boolean | (...args : readonly [unknown , A , From <E >]) => 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
AsyncQueryableRoot
<T
, E
>
The queryable result of the where operation.
Inherited from
Source
packages/verse-core/src/query/queryable.ts:592
with()
with<
S
>(navigation
:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>S
: (obj
:T
) =>S
):AsyncQueryableRoot
<T
,E
>
Used to specify eager loading of related entities in queries.
Type parameters
Type parameter |
---|
S |
Parameters
Parameter | Type | Description |
---|---|---|
navigation | T extends JoinResult <K > ? (...args : readonly [K ]) => S : (obj : T ) => S | The navigation property to be loaded. |
Returns
AsyncQueryableRoot
<T
, E
>
The queryable result of the with operation.