mongojs
mongojs copied to clipboard
Allow collection name mapping
Sometimes, collection name may not be in camelCase, it would be great if a mapping could be provided. Allow object to be passed, e.g.
var db = mongojs('mydb', {
collectionA: 'collection_a',
collectionB: 'collection-b',
});
I original posted as https://github.com/then/then-mongo/issues/5, find that it rely on mongojs implementation too.
I prefer to do something like this in my code
var db = mongojs('mydb', [
'collection_a',
'collection-b',
]);
module.exports = {
collectionA: db.collection_a,
collectionB: db.collection-b,
}
You can even do this if your on node 6+
var db = mongojs('mydb');
module.exports = Object.assign(db, {
collectionA: db.collection_a,
collectionB: db.collection-b
}