mirror of
https://github.com/vale981/grapher
synced 2025-03-06 10:01:40 -05:00
17 lines
No EOL
557 B
JavaScript
17 lines
No EOL
557 B
JavaScript
import Query from './query.js';
|
|
|
|
export default (data, params) => {
|
|
if (_.keys(data).length > 1) {
|
|
throw new Meteor.Error('invalid-query', 'When using createQuery you should only have one main root point.')
|
|
}
|
|
|
|
const collectionName = _.first(_.keys(data));
|
|
|
|
const collection = Mongo.Collection.get(collectionName);
|
|
|
|
if (!collection) {
|
|
throw new Meteor.Error('collection-not-found', `We could not find any collection with the name ${collectionName}`)
|
|
}
|
|
|
|
return new Query(collection, data[collectionName], params);
|
|
} |