mirror of
https://github.com/vale981/grapher
synced 2025-03-06 01:51:38 -05:00
Added promise (sync) variants of getCount
This commit is contained in:
parent
82be9fc76e
commit
98a83939b4
3 changed files with 23 additions and 3 deletions
|
@ -74,6 +74,14 @@ export default class extends Base {
|
||||||
return _.first(this.fetch(...args));
|
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.
|
* Gets the count of matching elements.
|
||||||
* @param callback
|
* @param callback
|
||||||
|
@ -117,4 +125,4 @@ export default class extends Base {
|
||||||
createGraph(this.collection, body)
|
createGraph(this.collection, body)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,14 @@ export default class Query extends Base {
|
||||||
return _.first(this.fetch(...args));
|
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.
|
* Gets the count of matching elements.
|
||||||
* @param callback
|
* @param callback
|
||||||
|
@ -117,4 +125,4 @@ export default class Query extends Base {
|
||||||
createGraph(this.collection, body)
|
createGraph(this.collection, body)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,5 +210,9 @@ describe('Query Client Tests', function () {
|
||||||
assert.isObject(result);
|
assert.isObject(result);
|
||||||
assert.isString(result._id);
|
assert.isString(result._id);
|
||||||
assert.isArray(result.posts);
|
assert.isArray(result.posts);
|
||||||
|
|
||||||
|
result = await query.getCountSync();
|
||||||
|
|
||||||
|
assert.isNumber(result);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue