Created
February 21, 2018 13:56
-
-
Save saintedlama/53b228e6ef2ef650afe3bdd9c5246429 to your computer and use it in GitHub Desktop.
Using exposed prototypes in mongoist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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