Class Query<T>Abstract

An abstract Query which allows retrieving results

Type Parameters

Hierarchy

Constructors

  • Type Parameters

    Parameters

    • entityManager: EntityManager

      The owning EntityManager of this query

    • resultClass: Class<T>

      The result class of this query

    Returns Query<T>

Properties

entityManager: EntityManager

The owning EntityManager of this query

resultClass: Class<T>

The result class of this query

MAX_URI_SIZE: 2000 = 2000

Methods

  • Parameters

    • limit: number

    Returns Node<T>

  • Parameters

    • offset: number

    Returns Node<T>

  • Parameters

    • field: string
    • order: 1 | -1

    Returns Node<T>

  • Parameters

    • order: {
          [field: string]: 1 | -1;
      }
      • [field: string]: 1 | -1

    Returns Node<T>

  • Add an ascending sort for the specified field to this query

    Returns

    The resulting Query

    Parameters

    • field: string

      The field to sort

    Returns Node<T>

  • Execute the query that returns the matching objects count.

    Returns

    The total number of matched objects

    Parameters

    • Optional doneCallback: CountCallback

      Called when the operation succeed.

    • Optional failCallback: FailCallback

      Called when there is a server-side error

    Returns Promise<number>

  • Add an decending sort for the specified field to this query

    Returns

    The resulting Query

    Parameters

    • field: string

      The field to sort

    Returns Node<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);
    

    Returns

    an observable

    Parameters

    Returns Observable<RealtimeEvent<T>>

  • 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)).

    Returns

    a real-time query subscription

    Parameters

    • Optional options: EventStreamOptions

      options to narrow down the events you will receive

    • Optional onNext: NextEventCallback<T>

      Called when an event is received

    • Optional onError: FailCallback

      Called when there is a server-side error

    • Optional onComplete: CompleteCallback

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

    Returns 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)).

    Returns

    a real-time query subscription

    Parameters

    • Optional onNext: NextEventCallback<T>

      Called when an event is received

    • Optional onError: FailCallback

      Called when there is a server-side error

    • Optional onComplete: CompleteCallback

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

    Returns Subscription

  • Execute the query and return the query results as a List

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

    Returns

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

    Parameters

    Returns Promise<T[]>

  • Execute the query and return the query results as a List

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

    Returns

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

    Parameters

    • Optional doneCallback: ResultListCallback<T>

      Called when the operation succeed.

    • Optional failCallback: FailCallback

      Called when the operation failed.

    Returns Promise<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);
    

    Returns

    an observable on which multiple subscriptions can be created on

    Parameters

    Returns Observable<T[]>

  • 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)).

    Returns

    a real-time query subscription handling complete query results.

    Parameters

    • Optional options: ResultStreamOptions

      additional options

    • Optional onNext: NextResultCallback<T>

      Called when the query result changes in any way

    • Optional onError: FailCallback

      Called when there is a server-side error

    • Optional onComplete: CompleteCallback

      Called when the network connection is closed (e.g. because of network timeout or lost Wi-Fi connection) and the specified number of reconnects have been exhausted; will never be called when infinite reconnects are configured (default)

    Returns 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.)

    Returns

    a real-time query subscription handling complete query results.

    Parameters

    • Optional onNext: NextResultCallback<T>

      Called when the query result changes in any way

    • Optional onError: FailCallback

      Called when there is a server-side error

    • Optional onComplete: CompleteCallback

      Called when the network connection is closed (e.g. because of network timeout or lost Wi-Fi connection) and the specified number of reconnects have been exhausted; will never be called when infinite reconnects are configured (default)

    Returns Subscription

  • Execute the query that returns a single result

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

    Returns

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

    Parameters

    Returns Promise<null | T>

  • Execute the query that returns a single result

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

    Returns

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

    Parameters

    Returns Promise<null | T>

  • Sets the sort of the query and discard all existing paramaters

    Returns

    The resulting Query

    See

    http://docs.mongodb.org/manual/reference/method/cursor.sort/

    Parameters

    • sort: {
          [field: string]: 1 | -1;
      }

      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

      • [field: string]: 1 | -1

    Returns Node<T>

Generated using TypeDoc