Skip to main content

Class: QueryableRoot<T>

Fluent query operators that must appear at the root of a compiled query expression.

Extends​

Type Parameters​

Type ParameterDescription
TThe type of the entity being queried.

Constructors​

new QueryableRoot()​

new QueryableRoot<T>(): QueryableRoot<T>

Returns​

QueryableRoot<T>

Inherited from​

Queryable.constructor

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​

ParameterTypeDescription
predicatePA function to test each element for a condition.

Returns​

boolean

true if all elements in the sequence satisfy the condition, otherwise false.

Inherited from​

Queryable.all

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​

ParameterTypeDescription
predicate?PA function to test each element for a condition.

Returns​

boolean

true if any elements in the sequence satisfy the condition, otherwise false.

Inherited from​

Queryable.any

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​

Queryable.array

Defined in​

packages/verse-core/src/query/queryable.ts:436


avg()​

avg(expr?: T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => number): number

Returns the average value of the specified numerical expression for the sequence.

Parameters​

ParameterTypeDescription
expr?T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => numberThe numerical expression to be evaluated.

Returns​

number

The average value of the specified numerical expression for the sequence.

Inherited from​

Queryable.avg

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​

Queryable.count

Defined in​

packages/verse-core/src/query/queryable.ts:388


distinct()​

distinct(): QueryableRoot<T>

Removes duplicate elements from the sequence.

Returns​

QueryableRoot<T>

The queryable result of the distinct operation.

Inherited from​

Queryable.distinct

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​

ParameterTypeDescription
predicate?PA 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​

Queryable.first

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​
ParameterTypeDescription
keyKA 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​

Queryable.groupBy

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​
ParameterTypeDescription
keyKA function to extract the key for each element.
result(param: Grouping<ReturnType<K>, T>) => RA function to create a result value from each group.
Returns​

Queryable<R>

The queryable result of the groupBy operation.

Inherited from​

Queryable.groupBy

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​

ParameterTypeDescription
entityOrQueryNewable<S> | Queryable<S>The entity or query to join with.
conditionCThe join condition.

Returns​

Queryable<JoinResult<Parameters<C>>>

The queryable result of the join operation.

Inherited from​

Queryable.join

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​

ParameterTypeDescription
entityOrQueryNewable<S> | Queryable<S>The entity or query to join with.
conditionCThe join condition.

Returns​

Queryable<JoinResult<Parameters<C>>>

The queryable result of the join operation.

Inherited from​

Queryable.leftJoin

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​

ParameterTypeDescription
limitnumberThe number of elements to return.

Returns​

QueryableRoot<T>

The queryable result of the limit operation.

Inherited from​

Queryable.limit

Defined in​

packages/verse-core/src/query/queryable.ts:297


max()​

max(expr?: T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => number): number

Returns the maximum value of the specified numerical expression for the sequence.

Parameters​

ParameterTypeDescription
expr?T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => numberThe numerical expression to be evaluated.

Returns​

number

The maximum value of the specified numerical expression for the sequence.

Inherited from​

Queryable.max

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​

ParameterTypeDescription
predicate?PA function to test each element for a condition.

Returns​

undefined | T

Inherited from​

Queryable.maybeFirst

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​

ParameterTypeDescription
predicate?PA 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​

Queryable.maybeSingle

Defined in​

packages/verse-core/src/query/queryable.ts:378


min()​

min(expr?: T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => number): number

Returns the minimum value of the specified numerical expression for the sequence.

Parameters​

ParameterTypeDescription
expr?T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => numberThe numerical expression to be evaluated.

Returns​

number

The minimum value of the specified numerical expression for the sequence.

Inherited from​

Queryable.min

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​

ParameterTypeDescription
offsetnumberThe number of elements to skip.

Returns​

QueryableRoot<T>

The queryable result of the offset operation.

Inherited from​

Queryable.offset

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​

ParameterTypeDescription
optionsQueryOptionsThe query options.

Returns​

QueryableRoot<T>

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​

ParameterTypeDescription
exprEA function to extract a sort key from an element.

Returns​

QueryableRoot<T>

The queryable result of the orderBy operation.

Inherited from​

Queryable.orderBy

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​

ParameterTypeDescription
exprEA function to extract a sort key from an element.

Returns​

QueryableRoot<T>

The queryable result of the orderByDesc operation.

Inherited from​

Queryable.orderByDesc

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​

ParameterTypeDescription
projectorPA function that transforms the input element.

Returns​

Queryable<ReturnType<P>>

The queryable result of the select operation.

Inherited from​

Queryable.select

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​

ParameterTypeDescription
predicate?PA 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​

Queryable.single

Defined in​

packages/verse-core/src/query/queryable.ts:365


sql()​

sql(strings: TemplateStringsArray, ...values: readonly any[]): QueryableRoot<T>

Inject a raw SQL query using tagged template literals. The returned queryable may be further composed with additional query operators.

Parameters​

ParameterTypeDescription
stringsTemplateStringsArrayThe SQL query template string.
...valuesreadonly any[]The values to be inserted into the query.

Returns​

QueryableRoot<T>

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 extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => number): number

Returns the sum of the specified numerical expression for the sequence.

Parameters​

ParameterTypeDescription
expr?T extends JoinResult<K> ? (...args: readonly [K]) => number : (obj: T) => numberThe numerical expression to be evaluated.

Returns​

number

The sum of the specified numerical expression for the sequence.

Inherited from​

Queryable.sum

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​

ParameterTypeDescription
predicatePA function to test each element for a condition.

Returns​

QueryableRoot<T>

The queryable result of the where operation.

Inherited from​

Queryable.where

Defined in​

packages/verse-core/src/query/queryable.ts:236


with()​

with<S>(navigation: T extends JoinResult<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​

ParameterTypeDescription
navigationT extends JoinResult<K> ? (...args: readonly [K]) => S : (obj: T) => SThe navigation property to be loaded.

Returns​

QueryableRoot<T>

The queryable result of the with operation.

Inherited from​

Queryable.with

Defined in​

packages/verse-core/src/query/queryable.ts:188