Query
The Query class is used to query for a subset of entities using the Kinvey API.
Example:
var query = new Kinvey.Query();
query.equalTo('name', 'Kinvey');
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object): Query Create an instance of the Query class. |
Member Summary
Public Members | ||
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
Method Summary
Public Methods | ||
public |
Adds a filter to the query. |
|
public |
Performs a logical AND operation on the query and the provided queries. |
|
public |
Adds an ascending sort modifier to the query. |
|
public |
Adds a contains filter to the query. |
|
public |
containsAll(field: string, values: Array): Query Adds a contains all filter to the query. |
|
public |
descending(field: string): Query Adds an descending sort modifier to the query. |
|
public |
Adds an equal to filter to the query. |
|
public |
Adds an exists filter to the query. |
|
public |
greaterThan(field: string, value: number | string): Query Adds a greater than filter to the query. |
|
public |
greaterThanOrEqualTo(field: string, value: number | string): Query Adds a greater than or equal to filter to the query. |
|
public |
Returns true or false depending on if the query is able to be processed offline. |
|
public |
Adds a less than filter to the query. |
|
public |
lessThanOrEqualTo(field: string, value: number | string): Query Adds a less than or equal to filter to the query. |
|
public |
Adds a match filter to the query. |
|
public |
Adds a modulus filter to the query. |
|
public |
Adds a near filter to the query. |
|
public |
Performs a logical NOR operation on the query and the provided queries. |
|
public |
notContainedIn(field: string, values: Array): Query Adds a not contained in filter to the query. |
|
public |
notEqualTo(field: string, value: *): Query Adds a not equal to filter to the query. |
|
public |
Performs a logical OR operation on the query and the provided queries. |
|
public |
Adds a size filter to the query. |
|
public |
Returns Object representation of the query. |
|
public |
Returns query string representation of the query. |
|
public |
Returns query string representation of the query. |
|
public |
withinBox(field: string, bottomLeftCoord: Array<number, number>, upperRightCoord: Array<number, number>): Query Adds a within box filter to the query. |
|
public |
Adds a within polygon filter to the query. |
Public Constructors
public constructor(options: Object): Query source
Create an instance of the Query class.
Params:
Name | Type | Attribute | Description |
options | Object | Options |
|
options.fields | string[] |
|
Fields to select. |
options.filter | Object |
|
MongoDB query. |
options.sort | Object |
|
The sorting order. |
options.limit | number |
|
Number of entities to select. |
options.skip | number |
|
Number of entities to skip from the start. |
Public Members
Public Methods
public addFilter(field: string, condition: string, values: *): Query source
Adds a filter to the query.
public and(args: ...Query | ...Object): Query source
Performs a logical AND operation on the query and the provided queries.
Throw:
|
public ascending(field: string): Query source
Adds an ascending sort modifier to the query. Sorts by field
, ascending.
Params:
Name | Type | Attribute | Description |
field | string | Field |
public contains(field: string, values: array): Query source
Adds a contains filter to the query. Requires field
to contain at least
one of the members of list
.
Params:
Name | Type | Attribute | Description |
field | string | Field |
|
values | array | List of values. |
Throw:
|
public containsAll(field: string, values: Array): Query source
Adds a contains all filter to the query. Requires field
to contain all
members of list
.
Throw:
|
public descending(field: string): Query source
Adds an descending sort modifier to the query. Sorts by field
,
descending.
Params:
Name | Type | Attribute | Description |
field | string | Field |
public equalTo(field: string, value: *): Query source
Adds an equal to filter to the query. Requires field
to equal value
.
Any existing filters on field
will be discarded.
Params:
Name | Type | Attribute | Description |
field | string | Field |
|
value | * | Value |
public exists(field: string, flag: boolean): Query source
Adds an exists filter to the query. Requires field
to exist if flag
is
true
, or not to exist if flag
is false
.
public greaterThan(field: string, value: number | string): Query source
Adds a greater than filter to the query. Requires field
to be greater
than value
.
Throw:
|
public greaterThanOrEqualTo(field: string, value: number | string): Query source
Adds a greater than or equal to filter to the query. Requires field
to
be greater than or equal to value
.
Throw:
|
public isSupportedOffline(): boolean source
Returns true or false depending on if the query is able to be processed offline.
public lessThan(field: string, value: number | string): Query source
Adds a less than filter to the query. Requires field
to be less than
value
.
Throw:
|
public lessThanOrEqualTo(field: string, value: number | string): Query source
Adds a less than or equal to filter to the query. Requires field
to be
less than or equal to value
.
Throw:
|
public matches(field: string, regExp: RegExp | string, options: Object): Query source
Adds a match filter to the query. Requires field
to match regExp
.
Params:
Name | Type | Attribute | Description |
field | string | Field |
|
regExp | RegExp | string | Regular expression. |
|
options | Object |
|
Options |
options.ignoreCase | boolean |
|
Toggles case-insensitivity. |
options.multiline | boolean |
|
Toggles multiline matching. |
options.extended | boolean |
|
Toggles extended capability. |
options.dotMatchesAll | boolean |
|
Toggles dot matches all. |
public mod(field: string, divisor: number, remainder: number): Query source
Adds a modulus filter to the query. Requires field
modulo divisor
to
have remainder remainder
.
Throw:
|
|
|
public near(field: string, coord: Array<number, number>, maxDistance: number): Query source
Adds a near filter to the query. Requires field
to be a coordinate
within maxDistance
of coord
. Sorts documents from nearest to farthest.
Throw:
|
public nor(args: ...Query | ...Object): Query source
Performs a logical NOR operation on the query and the provided queries.
Throw:
|
public notContainedIn(field: string, values: Array): Query source
Adds a not contained in filter to the query. Requires field
not to
contain any of the members of list
.
Throw:
|
public notEqualTo(field: string, value: *): Query source
Adds a not equal to filter to the query. Requires field
not to equal
value
.
Params:
Name | Type | Attribute | Description |
field | string | Field |
|
value | * | Value |
public or(args: ...Query | ...Object): Query source
Performs a logical OR operation on the query and the provided queries.
Throw:
|
public size(field: string, size: number): Query source
Adds a size filter to the query. Requires field
to be an Array
with
exactly size
members.
Throw:
|
public withinBox(field: string, bottomLeftCoord: Array<number, number>, upperRightCoord: Array<number, number>): Query source
Adds a within box filter to the query. Requires field
to be a coordinate
within the bounds of the rectangle defined by bottomLeftCoord
,
bottomRightCoord
.
Throw:
|
|
|