grapher/lib/db.js

22 lines
379 B
JavaScript
Raw Normal View History

2018-03-29 19:04:43 +03:00
import { Mongo } from 'meteor/mongo';
const db = new Proxy(
{},
{
get: function(obj, prop) {
const collection = Mongo.Collection.get(prop);
2018-03-29 19:04:43 +03:00
if (!collection) {
throw new Meteor.Error(
'collection-not-found',
`There is no collection with name ${prop}`
);
}
return collection;
},
}
);
2018-03-29 19:04:43 +03:00
export default db;