This topic has not yet been rated - Rate this topic

Query object

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The feature described in this topic is available only in preview. To use this feature and other new Windows Azure capabilities, sign up for the free preview.


Provides functionality for querying Windows Azure Mobile Services.

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.

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

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) { … }});

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.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter