Skip to content

Commit 440ad15

Browse files
committed
Move doCloudQuery to AV.Query
1 parent fd91db9 commit 440ad15

File tree

3 files changed

+9364
-33
lines changed

3 files changed

+9364
-33
lines changed

lib/av.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7502,6 +7502,35 @@
75027502
return query;
75037503
};
75047504

7505+
/**
7506+
* Retrieves a list of AVObjects that satisfy the CQL.
7507+
* CQL syntax please see https://cn.avoscloud.com/docs/cql_guide.html
7508+
* Either options.success or options.error is called when the find
7509+
* completes.
7510+
*
7511+
* @param {String} cql, A CQL string, see https://cn.avoscloud.com/docs/cql_guide.html
7512+
* @return {AV.Promise} A promise that is resolved with the results when
7513+
* the query completes.
7514+
*/
7515+
AV.Query.doCloudQuery = function(cql, options) {
7516+
var params = { cql: cql };
7517+
var request = AV._request("cloudQuery", null, null, 'GET', params)
7518+
return request.then(function(response) {
7519+
//query to process results.
7520+
var query = new AV.Query(response.className);
7521+
var results = _.map(response.results, function(json) {
7522+
var obj = query._newObject(response);
7523+
obj._finishFetch(query._processResult(json), true);
7524+
return obj;
7525+
});
7526+
return {
7527+
results: results,
7528+
count: response.count,
7529+
className: response.className
7530+
};
7531+
})._thenRunCallbacks(options);
7532+
};
7533+
75057534
AV.Query._extend = AV._extend;
75067535

75077536
AV.Query.prototype = {
@@ -8839,35 +8868,6 @@
88398868
})._thenRunCallbacks(options);
88408869
},
88418870

8842-
/**
8843-
* Retrieves a list of AVObjects that satisfy the CQL.
8844-
* CQL syntax please see https://cn.avoscloud.com/docs/cql_guide.html
8845-
* Either options.success or options.error is called when the find
8846-
* completes.
8847-
*
8848-
* @param {String} cql, A CQL string, see https://cn.avoscloud.com/docs/cql_guide.html
8849-
* @return {AV.Promise} A promise that is resolved with the results when
8850-
* the query completes.
8851-
*/
8852-
doCloudQuery: function(cql, options) {
8853-
var params = { cql: cql };
8854-
var request = AV._request("cloudQuery", null, null, 'GET', params)
8855-
return request.then(function(response) {
8856-
//query to process results.
8857-
var query = new AV.Query(response.className);
8858-
var results = _.map(response.results, function(json) {
8859-
var obj = query._newObject(response);
8860-
obj._finishFetch(query._processResult(json), true);
8861-
return obj;
8862-
});
8863-
return {
8864-
results: results,
8865-
count: response.count,
8866-
className: response.className
8867-
};
8868-
})._thenRunCallbacks(options);
8869-
},
8870-
88718871
/**
88728872
* Makes a call to request a sms code for operation verification.
88738873
* @param {Object} data The mobile phone number string or a JSON object contains mobilePhoneNumber,op,ttl,name etc.

0 commit comments

Comments
 (0)