Query
Query object provides database query functions.
Example:
const Note = skygear.Record.extend('note');
const query = new skygear.Query(Note);
query.equalTo('title', 'First note');
skygear.publicDB.query(query).then((notes) => {
}, (error) => {
console.error(error)
});'
Static Method Summary
| Static Public Methods | ||
| public static |
Returns a conjunctive query from queries. |
|
| public static |
Clones a Query object from a Query object. |
|
| public static |
fromJSON(payload: *): * Clones a Query object from payload. |
|
| public static |
Returns a negated query. |
|
| public static |
Returns a disjunctive query from queries. |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(recordCls: Record) Creates Query object from a Record Class. |
|
Member Summary
| Public Members | ||
| public get |
hash: string: * The computed Query object hash code |
|
| public |
limit: Number Limit of the query result |
|
| public |
offset: Number Offset of the query result |
|
| public |
overallCount: Boolean True if the query includes overall count |
|
| public |
page: Number Page of the query result |
|
| public get |
predicate: Array: * Preicate Function |
|
| public |
recordType: String Record type |
|
Method Summary
| Public Methods | ||
| public |
addAscending(key: string): Query Sets ascending predicate. |
|
| public |
addAscendingByDistance(key: string, loc: Geolocation): Query Sets ascending by distance predicate. |
|
| public |
addDescending(key: string): Query Sets descending predicate. |
|
| public |
addDescendingByDistance(key: string, loc: Geolocation): Query Sets descending by distance predicate. |
|
| public |
caseInsensitiveLike(key: string, value: string): Query Sets a case-insensitive like predicate. |
|
| public |
caseInsensitiveNotLike(key: string, value: string): Query Sets a case-insensitive negated like predicate. |
|
| public |
Sets a contains predicate. |
|
| public |
containsValue(key: string, needle: string): Query Sets a contains value predicate. |
|
| public |
distanceGreaterThan(key: string, loc: geolocation, distance: Number): Query Sets a distance greater than query. |
|
| public |
distanceLessThan(key: string, loc: Geolocation, distance: Number): Query Sets a distance less than query. |
|
| public |
Sets an equal predicate. |
|
| public |
greaterThan(key: string, value: string): Query Sets a greater than predicate. |
|
| public |
greaterThanOrEqualTo(key: string, value: string): Query Sets a greater than or equal to predicate. |
|
| public |
havingRelation(key: string, rel: string): Query Sets a having relation predicate. |
|
| public |
Sets a less than predicate. |
|
| public |
lessThanOrEqualTo(key: string, value: string): Query Sets a less than or equal to predicate. |
|
| public |
Sets a like predicate. |
|
| public |
notContains(key: string, lookupArray: Array): Query Sets a not contains predicate. |
|
| public |
notContainsValue(key: string, needle: string): Query Sets a not contains value predicate. |
|
| public |
notEqualTo(key: string, value: string): Query Sets a not equal predicate. |
|
| public |
notHavingRelation(key: string, rel: string): Query Sets a not having relation predicate. |
|
| public |
Sets a negated like predicate. |
|
| public |
toJSON(): object Serializes Query object. |
|
| public |
transientInclude(key: string, mapToKey: string): Query Sets transient include. |
|
| public |
transientIncludeDistance(key: string, mapToKey: string, loc: Geolocation): Query Sets transient include distance. |
|
Static Public Methods
public static and(queries: Query): * source
Returns a conjunctive query from queries.
Params:
| Name | Type | Attribute | Description |
| queries | Query | Queries |
Return:
| * |
public static clone(query: Query): * source
Clones a Query object from a Query object.
Params:
| Name | Type | Attribute | Description |
| query | Query | query to be cloned. |
Return:
| * |
public static fromJSON(payload: *): * source
Clones a Query object from payload.
Params:
| Name | Type | Attribute | Description |
| payload | * | Payload |
Return:
| * |
Public Constructors
Public Members
public get hash: string: * source
The computed Query object hash code
Return:
| string | md5 digest of serialized JSON |
Public Methods
public addAscending(key: string): Query source
Sets ascending predicate.
Params:
| Name | Type | Attribute | Description |
| key | string |
public addAscendingByDistance(key: string, loc: Geolocation): Query source
Sets ascending by distance predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| loc | Geolocation |
public addDescending(key: string): Query source
Sets descending predicate.
Params:
| Name | Type | Attribute | Description |
| key | string |
public addDescendingByDistance(key: string, loc: Geolocation): Query source
Sets descending by distance predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| loc | Geolocation |
public caseInsensitiveLike(key: string, value: string): Query source
Sets a case-insensitive like predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public caseInsensitiveNotLike(key: string, value: string): Query source
Sets a case-insensitive negated like predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public contains(key: string, lookupArray: Array): Query source
Sets a contains predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| lookupArray | Array | values |
Throw:
Throws Error if lookupArray is not an array. |
public containsValue(key: string, needle: string): Query source
Sets a contains value predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| needle | string |
Throw:
Throws Error if needle is not a string. |
public distanceGreaterThan(key: string, loc: geolocation, distance: Number): Query source
Sets a distance greater than query.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| loc | geolocation | ||
| distance | Number |
public distanceLessThan(key: string, loc: Geolocation, distance: Number): Query source
Sets a distance less than query.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| loc | Geolocation | ||
| distance | Number |
public equalTo(key: string, value: string): Query source
Sets an equal predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public greaterThan(key: string, value: string): Query source
Sets a greater than predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public greaterThanOrEqualTo(key: string, value: string): Query source
Sets a greater than or equal to predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public havingRelation(key: string, rel: string): Query source
Sets a having relation predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| rel | string | relationship, either 'friend' or 'follow' |
public lessThan(key: string, value: string): Query source
Sets a less than predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public lessThanOrEqualTo(key: string, value: string): Query source
Sets a less than or equal to predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public like(key: string, value: string): Query source
Sets a like predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public notContains(key: string, lookupArray: Array): Query source
Sets a not contains predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| lookupArray | Array | values |
Throw:
Throws Error if lookupArray is not an array. |
public notContainsValue(key: string, needle: string): Query source
Sets a not contains value predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| needle | string |
Throw:
Throws Error if needle is not a string. |
public notEqualTo(key: string, value: string): Query source
Sets a not equal predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public notHavingRelation(key: string, rel: string): Query source
Sets a not having relation predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| rel | string | relationship, either 'friend' or 'follow' |
public notLike(key: string, value: string): Query source
Sets a negated like predicate.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| value | string |
public transientInclude(key: string, mapToKey: string): Query source
Sets transient include.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| mapToKey | string |
public transientIncludeDistance(key: string, mapToKey: string, loc: Geolocation): Query source
Sets transient include distance.
Params:
| Name | Type | Attribute | Description |
| key | string | ||
| mapToKey | string | ||
| loc | Geolocation |
