mongojs icon indicating copy to clipboard operation
mongojs copied to clipboard

Allow collection name mapping

Open ratson opened this issue 9 years ago • 1 comments

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.

ratson avatar May 12 '16 16:05 ratson

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
}

saintedlama avatar Aug 08 '17 11:08 saintedlama