@riturajgc/upload-manager-service
Version:
Upload manager service for bitnudge
23 lines (18 loc) • 441 B
JavaScript
const mongoose = require('mongoose');
const getMongoose = ({ dbURL, dbConnectionObject }) => {
if (dbConnectionObject) {
return dbConnectionObject;
}
if (dbURL) {
mongoose.connect(dbURL).catch(err => {
console.error('MongoDB connection error:', err);
});
}
else {
throw new Error('Either `dbURL` or `dbConnectionObject` should be provided');
}
return mongoose;
};
module.exports = {
getMongoose,
};