Home Reference Source
public class | source

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

and(queries: Query): *

Returns a conjunctive query from queries.

public static

clone(query: Query): *

Clones a Query object from a Query object.

public static

fromJSON(payload: *): *

Clones a Query object from payload.

public static

not(query: Query): *

Returns a negated query.

public static

or(queries: Query): *

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

Sets ascending by distance predicate.

public

addDescending(key: string): Query

Sets descending predicate.

public

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

contains(key: string, lookupArray: Array): Query

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

equalTo(key: string, value: string): Query

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

lessThan(key: string, value: string): Query

Sets a less than predicate.

public

lessThanOrEqualTo(key: string, value: string): Query

Sets a less than or equal to predicate.

public

like(key: string, value: string): Query

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

notLike(key: string, value: string): Query

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:

NameTypeAttributeDescription
queries Query

Queries

Return:

*

public static clone(query: Query): * source

Clones a Query object from a Query object.

Params:

NameTypeAttributeDescription
query Query

query to be cloned.

Return:

*

public static fromJSON(payload: *): * source

Clones a Query object from payload.

Params:

NameTypeAttributeDescription
payload *

Payload

Return:

*

public static not(query: Query): * source

Returns a negated query.

Params:

NameTypeAttributeDescription
query Query

Query

Return:

*

public static or(queries: Query): * source

Returns a disjunctive query from queries.

Params:

NameTypeAttributeDescription
queries Query

Queries

Return:

*

Public Constructors

public constructor(recordCls: Record) source

Creates Query object from a Record Class.

Params:

NameTypeAttributeDescription
recordCls Record

Record Class

Public Members

public get hash: string: * source

The computed Query object hash code

Return:

string

md5 digest of serialized JSON

public limit: Number source

Limit of the query result

public offset: Number source

Offset of the query result

public overallCount: Boolean source

True if the query includes overall count

public page: Number source

Page of the query result

public get predicate: Array: * source

Preicate Function

Return:

Array

Array of {precidate}

public recordType: String source

Record type

Public Methods

public addAscending(key: string): Query source

Sets ascending predicate.

Params:

NameTypeAttributeDescription
key string

Return:

Query

self

public addAscendingByDistance(key: string, loc: Geolocation): Query source

Sets ascending by distance predicate.

Params:

NameTypeAttributeDescription
key string
loc Geolocation

Return:

Query

self

public addDescending(key: string): Query source

Sets descending predicate.

Params:

NameTypeAttributeDescription
key string

Return:

Query

self

public addDescendingByDistance(key: string, loc: Geolocation): Query source

Sets descending by distance predicate.

Params:

NameTypeAttributeDescription
key string
loc Geolocation

Return:

Query

self

public caseInsensitiveLike(key: string, value: string): Query source

Sets a case-insensitive like predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public caseInsensitiveNotLike(key: string, value: string): Query source

Sets a case-insensitive negated like predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public contains(key: string, lookupArray: Array): Query source

Sets a contains predicate.

Params:

NameTypeAttributeDescription
key string
lookupArray Array

values

Return:

Query

self

Throw:

Error

Throws Error if lookupArray is not an array.

public containsValue(key: string, needle: string): Query source

Sets a contains value predicate.

Params:

NameTypeAttributeDescription
key string
needle string

Return:

Query

self

Throw:

Error

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:

NameTypeAttributeDescription
key string
loc geolocation
distance Number

Return:

Query

self

public distanceLessThan(key: string, loc: Geolocation, distance: Number): Query source

Sets a distance less than query.

Params:

NameTypeAttributeDescription
key string
loc Geolocation
distance Number

Return:

Query

self

public equalTo(key: string, value: string): Query source

Sets an equal predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public greaterThan(key: string, value: string): Query source

Sets a greater than predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public greaterThanOrEqualTo(key: string, value: string): Query source

Sets a greater than or equal to predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public havingRelation(key: string, rel: string): Query source

Sets a having relation predicate.

Params:

NameTypeAttributeDescription
key string
rel string

relationship, either 'friend' or 'follow'

Return:

Query

self

public lessThan(key: string, value: string): Query source

Sets a less than predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public lessThanOrEqualTo(key: string, value: string): Query source

Sets a less than or equal to predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public like(key: string, value: string): Query source

Sets a like predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public notContains(key: string, lookupArray: Array): Query source

Sets a not contains predicate.

Params:

NameTypeAttributeDescription
key string
lookupArray Array

values

Return:

Query

self

Throw:

Error

Throws Error if lookupArray is not an array.

public notContainsValue(key: string, needle: string): Query source

Sets a not contains value predicate.

Params:

NameTypeAttributeDescription
key string
needle string

Return:

Query

self

Throw:

Error

Throws Error if needle is not a string.

public notEqualTo(key: string, value: string): Query source

Sets a not equal predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public notHavingRelation(key: string, rel: string): Query source

Sets a not having relation predicate.

Params:

NameTypeAttributeDescription
key string
rel string

relationship, either 'friend' or 'follow'

Return:

Query

self

public notLike(key: string, value: string): Query source

Sets a negated like predicate.

Params:

NameTypeAttributeDescription
key string
value string

Return:

Query

self

public toJSON(): object source

Serializes Query object.

Return:

object

public transientInclude(key: string, mapToKey: string): Query source

Sets transient include.

Params:

NameTypeAttributeDescription
key string
mapToKey string

Return:

Query

this

public transientIncludeDistance(key: string, mapToKey: string, loc: Geolocation): Query source

Sets transient include distance.

Params:

NameTypeAttributeDescription
key string
mapToKey string
loc Geolocation

Return:

Query

this