Eksportér (0) Udskriv
Udvid alt
EN
Dette indhold er ikke tilgængeligt på dit sprog, men her er den engelske version.

query object

Updated: August 25, 2012

Provides functionality for querying Microsoft Azure Mobile Services.

This object contains the following members:

 

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.

Vis:
© 2014 Microsoft