mirror of
https://github.com/vale981/grapher
synced 2025-03-11 21:36:39 -04:00
36 lines
821 B
JavaScript
36 lines
821 B
JavaScript
![]() |
import applyFilterFunction from '../query/lib/applyFilterFunction.js';
|
||
|
import deepClone from '../query/lib/deepClone.js';
|
||
|
import Base from './namedQuery.base';
|
||
|
|
||
|
export default class extends Base {
|
||
|
/**
|
||
|
* Retrieves the data.
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
fetch() {
|
||
|
const query = this.collection.createQuery(
|
||
|
deepClone(this.body),
|
||
|
deepClone(this.params)
|
||
|
);
|
||
|
|
||
|
return query.fetch();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param args
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
fetchOne(...args) {
|
||
|
return _.first(this.fetch(...args));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Gets the count of matching elements.
|
||
|
*
|
||
|
* @returns {any}
|
||
|
*/
|
||
|
getCount() {
|
||
|
let body = applyFilterFunction(this.body, this.params);
|
||
|
return this.collection.find(body.$filters || {}, {}).count();
|
||
|
}
|
||
|
}
|