I have a DB class that is built with a mongoDB connection, but I am uncertain about how to initiate a db instance within this setup.
import mongo from 'mongodb'
import Grid from 'gridfs-stream'
export default class Db {
constructor () {
this.connection = new mongo.Db('db', new mongo.Server('127.0.0.1', 27017))
}
async dropDB () {
const Users = this.connection.collection('users')
await Users.remove({})
}
}
In what way can I utilize this in my class?
db.open(function (err) {
if (err) return handleError(err);
var gfs = Grid(db, mongo);
})