Skip to content

Commit 487f1d0

Browse files
committed
add support for string condition argument in DataStore.getObjectCount
1 parent 78191de commit 487f1d0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/backendless.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@
13771377
/**
13781378
* Count of object
13791379
*
1380-
* @param {DataQueryBuilder} [queryBuilder]
1380+
* @param {String|DataQueryBuilder} [condition]
13811381
*
13821382
* @return {Promise}
13831383
*/
@@ -1386,27 +1386,33 @@
13861386
/**
13871387
* Count of object (sync)
13881388
*
1389-
* @param {DataQueryBuilder} [queryBuilder]
1389+
* @param {String|DataQueryBuilder} [condition]
13901390
*
13911391
* @return {number}
13921392
*/
13931393
getObjectCountSync: synchronized('_getObjectCount'),
13941394

1395-
_getObjectCount: function(queryBuilder, async) {
1396-
var args = this._parseFindArguments(arguments);
1397-
var dataQuery = args.queryBuilder ? args.queryBuilder.build() : {};
1395+
_getObjectCount: function(condition, async) {
1396+
if (condition instanceof Async) {
1397+
async = condition;
1398+
condition = null;
1399+
}
1400+
1401+
if (condition instanceof Backendless.DataQueryBuilder) {
1402+
condition = condition.build().condition;
1403+
}
1404+
13981405
var url = this.restUrl + '/count';
1399-
var isAsync = !!args.async;
14001406

1401-
if (dataQuery.condition) {
1402-
url += '?where=' + encodeURIComponent(dataQuery.condition);
1407+
if (condition) {
1408+
url += '?where=' + encodeURIComponent(condition);
14031409
}
14041410

14051411
return Backendless._ajax({
14061412
method : 'GET',
14071413
url : url,
1408-
isAsync : isAsync,
1409-
asyncHandler: args.async
1414+
isAsync : !!async,
1415+
asyncHandler: async
14101416
});
14111417
},
14121418

0 commit comments

Comments
 (0)