Class: QueryableRoot<T>
Fluent query operators that must appear at the root of a compiled query expression.
Extends
Queryable
<T
>
Type Parameters
Type Parameter | Description |
---|---|
T | The type of the entity being queried. |
Constructors
new QueryableRoot()
new QueryableRoot<
T
>():QueryableRoot
<T
>
Returns
Inherited from
Methods
all()
all<
P
>(predicate
:P
):boolean
Determines whether all elements of a sequence satisfy a condition.
Type Parameters
Type Parameter |
---|
P extends (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | P | A function to test each element for a condition. |
Returns
boolean
true
if all elements in the sequence satisfy the condition, otherwise false
.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:330
any()
any<
P
>(predicate
?:P
):boolean
Determines whether any element of a sequence satisfies a condition.
Type Parameters
Type Parameter |
---|
P extends (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | P | A function to test each element for a condition. |
Returns
boolean
true
if any elements in the sequence satisfy the condition, otherwise false
.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:319
array()
array():
Queryable
<T
[]>
Aggregates the elements of the sequence into an array.
Returns
Queryable
<T
[]>
An array of the elements in the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:436
avg()
avg(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):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
number
The average value of the specified numerical expression for the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:428
count()
count():
number
Returns the number of elements in the sequence.
Returns
number
The number of elements in the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:388
distinct()
distinct():
QueryableRoot
<T
>
Removes duplicate elements from the sequence.
Returns
The queryable result of the distinct operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:197
first()
first<
P
>(predicate
?:P
):T
Returns the first element of a sequence that satisfies a specified condition.
Type Parameters
Type Parameter |
---|
P extends (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | P | A function to test each element for a condition. |
Returns
T
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:342
groupBy()
groupBy(key)
groupBy<
K
>(key
:K
):Queryable
<{items
:T
[];key
:ReturnType
<K
>; }>
Groups the elements of a sequence according to a specified key selector function.
Type Parameters
Type Parameter |
---|
K extends (...args : readonly unknown []) => unknown | (obj : T ) => unknown |
Parameters
Parameter | Type | Description |
---|---|---|
key | K | A function to extract the key for each element. |
Returns
Queryable
<{items
: T
[];key
: ReturnType
<K
>; }>
The result of the groupBy operation.
items
items:
T
[]
key
key:
ReturnType
<K
>
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:268
groupBy(key, result)
groupBy<
K
,R
>(key
:K
,result
: (param
:Grouping
<ReturnType
<K
>,T
>) =>R
):Queryable
<R
>
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
Queryable
<R
>
The queryable result of the groupBy operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:280
join()
join<
S
,C
>(entityOrQuery
:Newable
<S
> |Queryable
<S
>,condition
:C
):Queryable
<JoinResult
<Parameters
<C
>>>
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 > | Queryable <S > | The entity or query to join with. |
condition | C | The join condition. |
Returns
Queryable
<JoinResult
<Parameters
<C
>>>
The queryable result of the join operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:209
leftJoin()
leftJoin<
S
,C
>(entityOrQuery
:Newable
<S
> |Queryable
<S
>,condition
:C
):Queryable
<JoinResult
<Parameters
<C
>>>
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 > | Queryable <S > | The entity or query to join with. |
condition | C | The join condition. |
Returns
Queryable
<JoinResult
<Parameters
<C
>>>
The queryable result of the join operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:220
limit()
limit(
limit
:number
):QueryableRoot
<T
>
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
The queryable result of the limit operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:297
max()
max(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):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
number
The maximum value of the specified numerical expression for the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:408
maybeFirst()
maybeFirst<
P
>(predicate
?:P
):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 (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | P | A function to test each element for a condition. |
Returns
undefined
| T
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:353
maybeSingle()
maybeSingle<
P
>(predicate
?:P
):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 (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | P | A function to test each element for a condition. |
Returns
undefined
| T
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:378
min()
min(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):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
number
The minimum value of the specified numerical expression for the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:398
offset()
offset(
offset
:number
):QueryableRoot
<T
>
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
The queryable result of the offset operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:308
options()
options(
options
:QueryOptions
):QueryableRoot
<T
>
Set query options that affect the behaviour of the query.
Parameters
Parameter | Type | Description |
---|---|---|
options | QueryOptions | The query options. |
Returns
The queryable with the specified options applied.
Example
const query =
db.compile(from =>
from.albums.options({ disabledConditions: ["soft delete"] }));
Defined in
packages/verse-core/src/query/queryable.ts:476
orderBy()
orderBy<
E
>(expr
:E
):QueryableRoot
<T
>
Sorts the elements of a sequence in ascending order.
Type Parameters
Type Parameter |
---|
E extends (...args : readonly unknown []) => unknown | (obj : T ) => unknown |
Parameters
Parameter | Type | Description |
---|---|---|
expr | E | A function to extract a sort key from an element. |
Returns
The queryable result of the orderBy operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:247
orderByDesc()
orderByDesc<
E
>(expr
:E
):QueryableRoot
<T
>
Sorts the elements of a sequence in descending order.
Type Parameters
Type Parameter |
---|
E extends (...args : readonly unknown []) => unknown | (obj : T ) => unknown |
Parameters
Parameter | Type | Description |
---|---|---|
expr | E | A function to extract a sort key from an element. |
Returns
The queryable result of the orderByDesc operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:258
select()
select<
P
>(projector
:P
):Queryable
<ReturnType
<P
>>
Projects each element of a sequence into a new form.
Type Parameters
Type Parameter |
---|
P extends (obj : T ) => unknown | (...args : readonly unknown []) => unknown |
Parameters
Parameter | Type | Description |
---|---|---|
projector | P | A function that transforms the input element. |
Returns
Queryable
<ReturnType
<P
>>
The queryable result of the select operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:177
single()
single<
P
>(predicate
?:P
):T
Returns the only element of a sequence that satisfies a specified condition.
Type Parameters
Type Parameter |
---|
P extends (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | P | A function to test each element for a condition. |
Returns
T
The only element in the sequence that satisfies the condition.
Throws
Error, if no such element is found, or multiple elements satisfy the condition.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:365
sql()
sql(
strings
:TemplateStringsArray
, ...values
: readonlyany
[]):QueryableRoot
<T
>
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
The queryable result of the injected SQL query.
Example
const query = db.compile(from => from.albums.sql`select * from "Album"`);
const albums = await query.toArray()
Defined in
packages/verse-core/src/query/queryable.ts:460
sum()
sum(
expr
?:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>number
: (obj
:T
) =>number
):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
number
The sum of the specified numerical expression for the sequence.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:418
where()
where<
P
>(predicate
:P
):QueryableRoot
<T
>
Filters a sequence of values based on a predicate.
Type Parameters
Type Parameter |
---|
P extends (obj : T , ...args : []) => boolean | (...args : readonly unknown []) => boolean |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | P | A function to test each element for a condition. |
Returns
The queryable result of the where operation.
Inherited from
Defined in
packages/verse-core/src/query/queryable.ts:236
with()
with<
S
>(navigation
:T
extendsJoinResult
<K
> ? (...args
: readonly [K
]) =>S
: (obj
:T
) =>S
):QueryableRoot
<T
>
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
The queryable result of the with operation.