Skip to content

Commit b9cd317

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 5688b18 + 96d8b12 commit b9cd317

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backendless",
3-
"version": "6.6.2",
3+
"version": "6.6.3",
44
"description": "Backendless JavaScript SDK for Node.js and the browser",
55
"browser": "dist/backendless.js",
66
"main": "lib/index.js",

src/data/store.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ export default class DataStore {
166166

167167
async getObjectCount(condition) {
168168
let distinct = undefined
169+
let groupBy = undefined
169170

170171
if (condition) {
171172
if (condition instanceof DataQueryBuilder) {
172173
distinct = condition.getDistinct() || undefined
174+
groupBy = condition.getGroupBy() || undefined
173175
condition = condition.getWhereClause() || undefined
174176
} else if (typeof condition !== 'string') {
175177
throw new Error('Condition must be a string or an instance of DataQueryBuilder.')
@@ -178,7 +180,7 @@ export default class DataStore {
178180

179181
return this.app.request.post({
180182
url : this.app.urls.dataTableCount(this.className),
181-
data: { where: condition, distinct },
183+
data: { where: condition, distinct, groupBy },
182184
})
183185
}
184186

test/unit/specs/data/find.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,31 @@ describe('<Data> Find', function() {
777777
expect(result3).to.be.equal(4)
778778
})
779779

780+
it('with groupBy ', async () => {
781+
const req = prepareMockRequest(2)
782+
783+
const query = Backendless.Data.QueryBuilder.create()
784+
785+
query.setGroupBy('objectId')
786+
query.setWhereClause('foo>123')
787+
788+
const result = await dataStore.getObjectCount(query)
789+
790+
expect(req).to.deep.include({
791+
method : 'POST',
792+
path : `${APP_PATH}/data/${tableName}/count`,
793+
headers: {
794+
'Content-Type': 'application/json'
795+
},
796+
body : {
797+
where : 'foo>123',
798+
groupBy: ['objectId']
799+
}
800+
})
801+
802+
expect(result).to.be.equal(2)
803+
})
804+
780805
it('fails when at least one item is invalid', async () => {
781806
const errorMsg = 'Condition must be a string or an instance of DataQueryBuilder.'
782807

0 commit comments

Comments
 (0)