mirror of
https://github.com/vale981/grapher
synced 2025-03-05 17:41:41 -05:00
Merge pull request #76 from jbbr/promise-count
Adds promise (sync) variants of getCount
This commit is contained in:
commit
46f9d8b388
3 changed files with 23 additions and 3 deletions
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue