(callback)
| 740 | }; |
| 741 | |
| 742 | count(callback) { |
| 743 | if (!CB.appId) { |
| 744 | throw "CB.appId is null."; |
| 745 | } |
| 746 | if (!this.tableName) { |
| 747 | throw "TableName is null."; |
| 748 | } |
| 749 | var def; |
| 750 | if (!callback) { |
| 751 | def = new CB.Promise(); |
| 752 | } |
| 753 | var thisObj = this; |
| 754 | var params = JSON.stringify({query: thisObj.query, limit: thisObj.limit, skip: thisObj.skip, key: CB.appKey}); |
| 755 | var url = CB.apiUrl + "/data/" + CB.appId + "/" + thisObj.tableName + '/count'; |
| 756 | |
| 757 | CB._request('POST', url, params).then(function(response) { |
| 758 | response = parseInt(response); |
| 759 | if (callback) { |
| 760 | callback.success(response); |
| 761 | } else { |
| 762 | def.resolve(response); |
| 763 | } |
| 764 | }, function(err) { |
| 765 | if (callback) { |
| 766 | callback.error(err); |
| 767 | } else { |
| 768 | def.reject(err); |
| 769 | } |
| 770 | }); |
| 771 | |
| 772 | if (!callback) { |
| 773 | return def.promise; |
| 774 | } |
| 775 | }; |
| 776 | |
| 777 | distinct(keys, callback) { |
| 778 |
no outgoing calls
no test coverage detected