setup-mongodb
v1.0.1
Published
This plugin allows you to setup multiple mongoDB in a cleaner way and ensures DB is connected before accessing it.
Downloads
2
Maintainers
Readme
setup-mongodb
This plugin allows you to setup multiple mongoDB in a cleaner way and ensures DB is connected before accessing it.
adminDB.js
import setupMongoDB from 'setup-mongodb'
const uri = process.env.ADMIN_URI
const eventSchema = createEventSchema(),
sessionSchema = createSessionSchema(),
adminSchema = createAdminSchema()
const schemas = {
admin: adminSchema,
session: sessionSchema
}
const connectDB = setupMongoDB(uri, schemas)
export default connectDB
api
import connectDB from './adminDB'
const { conn, adminModel, waitForConnection } = connectDB()
await waitForConnection()
await adminModel.findOne({ username })