Skip to content

Instantly share code, notes, and snippets.

@saintedlama
Created February 21, 2018 13:56
Show Gist options
  • Save saintedlama/53b228e6ef2ef650afe3bdd9c5246429 to your computer and use it in GitHub Desktop.
Save saintedlama/53b228e6ef2ef650afe3bdd9c5246429 to your computer and use it in GitHub Desktop.
Using exposed prototypes in mongoist
const mongoist = require('mongoist');
module.exports = mongoist('test');
module.exports.Database = mongoist.Database;
module.exports.Collection = mongoist.Collection;
module.exports.Cursor = mongoist.Cursor;
module.exports.Bulk = mongoist.Bulk;
const db = require('./db');
db.Collection.prototype.find = () => [{ bar: 'foo' }];
async function doDbStuff() {
await db.a.insert({ foo: 'bar'});
const res = await db.a.find();
console.log(res);
db.close();
}
doDbStuff();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment