Home Reference Source Test
public class | source

Query

This class represents a Query object. Queries are constructed using the static helper methods.

Static Method Summary

Static Public Methods
public static

and(var_args: ...Query): Query

Returns the conjunction of multiple queries.

public static

between(indexName: string, lower: *, upper: *): Query

Returns a query that matches all keys of an index that are between two values, excluding the boundaries.

public static

eq(indexName: string, val: *): Query

Returns a query that matches all keys of an index that equal to a value.

public static

ge(indexName: string, val: *): Query

Returns a query that matches all keys of an index that are greater or equal than a value.

public static

gt(indexName: string, val: *): Query

Returns a query that matches all keys of an index that are greater than a value.

public static

le(indexName: string, val: *): Query

Returns a query that matches all keys of an index that are less or equal than a value.

public static

lt(indexName: string, val: *): Query

Returns a query that matches all keys of an index that are less than a value.

public static

max(indexName: string): Query

Returns a query for the max key of an index.

public static

min(indexName: string): Query

Returns a query for the min key of an index.

public static

or(var_args: ...Query): Query

Returns the disjunction of multiple queries.

public static

within(indexName: string, lower: *, upper: *): Query

Returns a query that matches all keys of an index that are between two values, including the boundaries.

Method Summary

Public Methods
public

keys(objectStore: IObjectStore, limit: number): Promise<Set<string>>

Returns a promise of a set of keys fulfilling this query.

public

async values(objectStore: IObjectStore, limit: number): Promise<Array<*>>

Returns a promise of an array of objects fulfilling this query.

Static Public Methods

public static and(var_args: ...Query): Query source

Returns the conjunction of multiple queries.

Params:

NameTypeAttributeDescription
var_args ...Query

The list of queries, which all have to be fulfilled.

Return:

Query

The conjunction of the queries.

public static between(indexName: string, lower: *, upper: *): Query source

Returns a query that matches all keys of an index that are between two values, excluding the boundaries. The query matches all keys k, such that lower < k < upper.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

lower *

The lower bound.

upper *

The upper bound.

Return:

Query

The resulting query object.

public static eq(indexName: string, val: *): Query source

Returns a query that matches all keys of an index that equal to a value. The query matches all keys k, such that k = val.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

val *

The value to look for.

Return:

Query

The resulting query object.

public static ge(indexName: string, val: *): Query source

Returns a query that matches all keys of an index that are greater or equal than a value. The query matches all keys k, such that k ≥ val.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

val *

The lower bound of the query.

Return:

Query

The resulting query object.

public static gt(indexName: string, val: *): Query source

Returns a query that matches all keys of an index that are greater than a value. The query matches all keys k, such that k > val.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

val *

The lower bound of the query.

Return:

Query

The resulting query object.

public static le(indexName: string, val: *): Query source

Returns a query that matches all keys of an index that are less or equal than a value. The query matches all keys k, such that k ≤ val.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

val *

The upper bound of the query.

Return:

Query

The resulting query object.

public static lt(indexName: string, val: *): Query source

Returns a query that matches all keys of an index that are less than a value. The query matches all keys k, such that k < val.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

val *

The upper bound of the query.

Return:

Query

The resulting query object.

public static max(indexName: string): Query source

Returns a query for the max key of an index.

Params:

NameTypeAttributeDescription
indexName string

The name of the index, whose maximal key the query matches.

Return:

Query

The query for the max key of the index.

public static min(indexName: string): Query source

Returns a query for the min key of an index.

Params:

NameTypeAttributeDescription
indexName string

The name of the index, whose minimal key the query matches.

Return:

Query

The query for the min key of the index.

public static or(var_args: ...Query): Query source

Returns the disjunction of multiple queries.

Params:

NameTypeAttributeDescription
var_args ...Query

The list of queries, out of which at least one has to be fulfilled.

Return:

Query

The disjunction of the queries.

public static within(indexName: string, lower: *, upper: *): Query source

Returns a query that matches all keys of an index that are between two values, including the boundaries. The query matches all keys k, such that lower ≤ k ≤ upper.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

lower *

The lower bound.

upper *

The upper bound.

Return:

Query

The resulting query object.

Public Methods

public keys(objectStore: IObjectStore, limit: number): Promise<Set<string>> source

Returns a promise of a set of keys fulfilling this query.

Params:

NameTypeAttributeDescription
objectStore IObjectStore

The object store to execute the query on.

limit number
  • optional

Limits the number of results if given.

Return:

Promise<Set<string>>

A promise of the set of keys relevant to this query.

public async values(objectStore: IObjectStore, limit: number): Promise<Array<*>> source

Returns a promise of an array of objects fulfilling this query.

Params:

NameTypeAttributeDescription
objectStore IObjectStore

The object store to execute the query on.

limit number
  • optional

Limits the number of results if given.

Return:

Promise<Array<*>>

A promise of the array of objects relevant to this query.