query object

 

Provides functionality for querying Microsoft Azure Mobile Services.

Members

This object contains the following members:

Methods

Syntax

Returns

Description

orderBy

Query.orderBy(arg1, arg2, …)

Query

Returns a Query object where the query is ordered by the supplied column name arguments, in ascending order.

        friendsTable.orderBy('name')
    .read({ success: function(results) { … }});

      

orderByDescending

Query.orderByDescending(arg1, arg2, …)

Query

Returns a Query object where the query is ordered by the supplied column name arguments, in descending order.

        friendsTable.orderByDescending('name')
    .read({ success: function(results) { … }});

      

read

Query.read(options)

undefined

Reads all data from the table and invokes the success handler specified on the options parameter passing in an array of results.

System_CAPS_importantImportant

You should not call the read method on tables of unbounded size.

</td>

select

Query.select(col1, col2, …)

Query

Returns a Query object with the requested column projection applied.

        friendsTable.select('friendId', 'approved')
    .read({ success: function(results) { console.log(results) }});

      

Query.select(function)

Query

Returns a Query object with the requested function projection applied.

        friendsTable.select(function() { return this.friendId; })
    .read({ success: function(results) { console.log(results); }});

      

skip

Query.skip(recordCount)

Query

Returns a Query object that skips the first recordCount number of records.

take

Query.take(recordCount)

Query

Returns a Query object that returns the recordCount number of records.

where

Query.where(object)

Query

Returns a Query object that is filtered based on the property values of the supplied JSON object.

        friendsTable.where({ userId: user.userId, approved: true})
    .read({ success: function(results) { … }});

      

Query.where(function)

Query

Returns a new Query object that is filtered based on the supplied function.

        friendsTable.where(function(currentUserId){ 
    return this.userId == currentUserId && this.approved == true;
}, user.userId)
    .read({ success: function(results) { … }});

      

Remarks

The Query object is passed to read scripts.

Query methods (orderBy, orderByDescending, select, skip, take and where all return a new Query object. This enables you to compose queries as a series of method calls.

To see usage examples for the options object, go to options object

See Also

Mobile Services JavaScript (Node.js) backend library