Class: Node

query.Node(entityManager, resultClass)

A Query Node saves the state of the query being built

Constructor

new Node(entityManager, resultClass)

Parameters:
Name Type Description
entityManager EntityManager

The owning entity manager of this query

resultClass Class.<T>

The query result class

Source:

Extends

Members

(readonly) entityManager :EntityManager

The owning EntityManager of this query

Type:
Inherited From:
Source:

(readonly) firstResult :number

The offset how many results should be skipped

Type:
  • number
Source:

(readonly) maxResults :number

The limit how many objects should be returned

Type:
  • number
Source:

(readonly) order :Object.<string, number>

The properties which should be used sort the result

Type:
  • Object.<string, number>
Source:

(readonly) resultClass :Class.<T>

The result class of this query

Type:
  • Class.<T>
Inherited From:
Source:

Methods

ascending(field) → {this}

Add an ascending sort for the specified field to this query

Parameters:
Name Type Description
field string

The field to sort

Inherited From:
Source:
Returns:

The resulting Query

Type
this

count(doneCallbackopt, failCallbackopt) → {Promise.<number>}

Execute the query that returns the matching objects count.

Parameters:
Name Type Attributes Description
doneCallback query.Query~countCallback <optional>

Called when the operation succeed.

failCallback query.Query~failCallback <optional>

Called when there is a server-side error

Overrides:
Source:
Returns:

The total number of matched objects

Type
Promise.<number>

descending(field) → {this}

Add an decending sort for the specified field to this query

Parameters:
Name Type Description
field string

The field to sort

Inherited From:
Source:
Returns:

The resulting Query

Type
this

eventStream(onNextopt, onErroropt, onCompleteopt) → {Subscription}

Returns a subscription that handles change events for a real-time query.

The underlying stream object is hidden. To create multiple subscriptions on the same stream, create the stream
object first and then subscribe to the stream (see the other signature #eventStream(options)).

Parameters:
Name Type Attributes Description
onNext query.Query~nextEventCallback <optional>

Called when an event is received

onError query.Query~failCallback <optional>

Called when there is a server-side error

onComplete query.Query~completeCallback <optional>

Called when the network connection is closed (e.g. because of
lost Wi-Fi connection)

Overrides:
Source:
Returns:

a real-time query subscription

Type
Subscription

limit(limit) → {this}

Sets the limit of this query, i.e hox many objects should be returnd

Parameters:
Name Type Description
limit number

The limit of this query

Inherited From:
Source:
See:
Returns:

The resulting Query

Type
this

offset(offset) → {this}

Sets the offset of the query, i.e. how many elements should be skipped

Parameters:
Name Type Description
offset number

The offset of this query

Inherited From:
Source:
See:
Returns:

The resulting Query

Type
this

resultList(doneCallbackopt, failCallbackopt) → {Promise.<Array.<T>>}

Execute the query and return the query results as a List

Note: All local unsaved changes on matching objects, will be discarded.

Parameters:
Name Type Attributes Description
doneCallback query.Query~resultListCallback <optional>

Called when the operation succeed.

failCallback query.Query~failCallback <optional>

Called when the operation failed.

Overrides:
Source:
Returns:

A promise that will be resolved with the query result as a list

Type
Promise.<Array.<T>>

resultStream(onNextopt, onErroropt) → {Subscription}

Returns a subscription that handles the complete real-time query result

The full result is received initially (i.e. on subscription) and on every change.

The underlying stream object is hidden. To create multiple subscriptions on the same stream, create the stream
object first and then subscribe to the stream (see the other signature #resultStream(options)).

As the real-time query will reconnect infinitely often, there is no onComplete callback. (In other words, the
observable will never complete.)

Parameters:
Name Type Attributes Description
onNext query.Query~nextResultCallback <optional>

Called when the query result changes in any way

onError query.Query~failCallback <optional>

Called when there is a server-side error

Overrides:
Source:
Returns:

a real-time query subscription handling complete query results.

Type
Subscription

singleResult(doneCallbackopt, failCallbackopt) → {Promise.<?T>}

Execute the query that returns a single result

Note: All local unsaved changes on the matched object, will be discarded.

Parameters:
Name Type Attributes Description
doneCallback query.Query~singleResultCallback <optional>

Called when the operation succeed.

failCallback query.Query~failCallback <optional>

Called when the operation failed.

Overrides:
Source:
Returns:

A promise that will be resolved with the query result as a single result

Type
Promise.<?T>

sort(sort) → {this}

Sets the sort of the query and discard all existing paramaters

Parameters:
Name Type Description
sort Object.<string, number>

The new sort of the query which is an object whose keys are fields and the
values are either +1 for ascending order or -1 for descending order

Inherited From:
Source:
See:
Returns:

The resulting Query

Type
this