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
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
.
Inherited from
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 (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
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.
Inherited from
Defined in
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
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.
Inherited from
Defined in
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
Defined in
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
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.
Inherited from
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.
Inherited from
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
>
Inherited from
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.
Inherited from
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.
Inherited from
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.
Inherited from
Defined in
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
Defined in
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
Defined in
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
Defined in
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
Defined in
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.
Throws
Error, if multiple elements satisfy the condition.
Inherited from
Defined in
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.
Throws
Error, if multiple elements satisfy the condition.
Inherited from
Defined in
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
Defined in
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
Defined in
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"] });
Defined in
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. |