diff --git a/lib/namedQuery/namedQuery.client.js b/lib/namedQuery/namedQuery.client.js index cdbb6c0..348af23 100644 --- a/lib/namedQuery/namedQuery.client.js +++ b/lib/namedQuery/namedQuery.client.js @@ -74,6 +74,14 @@ export default class extends Base { return _.first(this.fetch(...args)); } + /** + * Gets the count of matching elements in sync. + * @returns {any} + */ + async getCountSync() { + return await callWithPromise(this.name + '.count', prepareForProcess(this.body, this.params)); + } + /** * Gets the count of matching elements. * @param callback @@ -117,4 +125,4 @@ export default class extends Base { createGraph(this.collection, body) ); } -} \ No newline at end of file +} diff --git a/lib/query/query.client.js b/lib/query/query.client.js index 48f7764..fed9996 100644 --- a/lib/query/query.client.js +++ b/lib/query/query.client.js @@ -74,6 +74,14 @@ export default class Query extends Base { return _.first(this.fetch(...args)); } + /** + * Gets the count of matching elements in sync. + * @returns {any} + */ + async getCountSync() { + return await callWithPromise(this.name + '.count', prepareForProcess(this.body, this.params)); + } + /** * Gets the count of matching elements. * @param callback @@ -117,4 +125,4 @@ export default class Query extends Base { createGraph(this.collection, body) ); } -} \ No newline at end of file +} diff --git a/lib/query/testing/client.test.js b/lib/query/testing/client.test.js index 9069f9b..3c5d052 100644 --- a/lib/query/testing/client.test.js +++ b/lib/query/testing/client.test.js @@ -210,5 +210,9 @@ describe('Query Client Tests', function () { assert.isObject(result); assert.isString(result._id); assert.isArray(result.posts); + + result = await query.getCountSync(); + + assert.isNumber(result); }) -}); \ No newline at end of file +});