mirror of
https://github.com/vale981/grapher
synced 2025-03-13 22:26:40 -04:00
36 lines
851 B
JavaScript
36 lines
851 B
JavaScript
![]() |
import createGraph from './lib/createGraph.js';
|
||
|
import applyFilterFunction from './lib/applyFilterFunction.js';
|
||
|
import hypernova from './hypernova/hypernova.js';
|
||
|
import Base from './query.base';
|
||
|
|
||
|
export default class Query extends Base {
|
||
|
/**
|
||
|
* Retrieves the data.
|
||
|
* @param options
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
fetch(options = {}) {
|
||
|
const node = createGraph(
|
||
|
this.collection,
|
||
|
applyFilterFunction(this.body, this.params)
|
||
|
);
|
||
|
|
||
|
return hypernova(node, options.userId);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param args
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
fetchOne(...args) {
|
||
|
return _.first(this.fetch(...args));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Gets the count of matching elements.
|
||
|
* @returns {integer}
|
||
|
*/
|
||
|
getCount() {
|
||
|
return this.collection.find(this.body.$filters || {}, {}).count();
|
||
|
}
|
||
|
}
|