Members
(readonly) entityManager :EntityManager
The owning EntityManager of this query
Type:
- Source:
(readonly) resultClass :Class.<T>
The result class of this query
Type:
- Class.<T>
- 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 |
- 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 |
- 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 |
- Source:
Returns:
The resulting Query
- Type
- this
eventStream(optionsopt, 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 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options to narrow down the events you will receive |
||||||||||||||||||||
Properties
|
|||||||||||||||||||||||
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 |
- Source:
Returns:
a real-time query subscription
- Type
- Subscription
eventStream(optionsopt) → {Observable.<RealtimeEvent.<T>>}
Returns an observable that receives change events for a real-time query
Multiple subscriptions can be created on top of this observable:
var query = DB.Todo.find();
var options = { ... };
var stream = query.eventStream(options);
var sub = stream.subscribe(onNext, onError, onComplete);
var otherSub = stream.subscribe(otherOnNext, otherOnError, otherOnComplete);
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options to narrow down the events you will receive |
||||||||||||||||||||
Properties
|
- Source:
Returns:
an observable
- Type
- Observable.<RealtimeEvent.<T>>
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 |
- 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 |
- 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 |
- 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. |
- Source:
Returns:
A promise that will be resolved with the query result as a list
- Type
- Promise.<Array.<T>>
resultList(optionsopt, 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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The query options |
||||||||||
Properties
|
|||||||||||||
doneCallback |
query.Query~resultListCallback |
<optional> |
Called when the operation succeed. |
||||||||||
failCallback |
query.Query~failCallback |
<optional> |
Called when the operation failed. |
- Source:
Returns:
A promise that will be resolved with the query result as a list
- Type
- Promise.<Array.<T>>
resultStream(optionsopt, onNextopt, onErroropt, onCompleteopt) → {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)
).
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
additional options |
||||||||||
Properties
|
|||||||||||||
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 |
||||||||||
onComplete |
query.Query~completeCallback |
<optional> |
Called when the network connection is closed (e.g. because of |
- Source:
Returns:
a real-time query subscription handling complete query results.
- Type
- Subscription
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 |
- Source:
Returns:
a real-time query subscription handling complete query results.
- Type
- Subscription
resultStream(optionsopt) → {Observable.<Array.<T>>}
Returns an observable that receives the complete real-time query result
The full result is received initially (i.e. on subscription) and on every change.
var query = DB.Todo.find();
var stream = query.resultStream();
var sub = stream.subscribe(onNext, onError, onComplete);
var otherSub = stream.subscribe(otherOnNext, otherOnError, otherOnComplete);
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
additional options |
||||||||||
Properties
|
- Source:
Returns:
an observable on which multiple subscriptions can be created on
- Type
- Observable.<Array.<T>>
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. |
- Source:
Returns:
A promise that will be resolved with the query result as a single result
- Type
- Promise.<?T>
singleResult(optionsopt, 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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The query options |
||||||||||
Properties
|
|||||||||||||
doneCallback |
query.Query~singleResultCallback |
<optional> |
Called when the operation succeed. |
||||||||||
failCallback |
query.Query~failCallback |
<optional> |
Called when the operation failed. |
- 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 |
- Source:
- See:
Returns:
The resulting Query
- Type
- this