Add full project files
This commit is contained in:
24
boot/mongo.js
Normal file
24
boot/mongo.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// const mongoose = require('mongoose')
|
||||
// const { MONGO_DBNAME, MONGO_HOST, MONGO_PORT } = process.env
|
||||
// mongoose.connection.on('error', (error) => {
|
||||
// console.log('mongodb connection failed! ', error.message)
|
||||
// })
|
||||
// const startMongoDB = () => {
|
||||
// mongoose.connect(`mongodb://${MONGO_HOST}:${MONGO_PORT}/${MONGO_DBNAME}`, {
|
||||
// })
|
||||
// }
|
||||
// module.exports = startMongoDB
|
||||
|
||||
const mongoose = require('mongoose')
|
||||
mongoose.connection.on('error', (error) => {
|
||||
console.log('mongodb connection failed! ', error.message)
|
||||
})
|
||||
mongoose.connection.on('open', function () {
|
||||
console.log('Database Connected! ')
|
||||
})
|
||||
const startMongoDB = () => {
|
||||
mongoose.connect(process.env.DATABASE_URL, {
|
||||
authSource: 'admin'
|
||||
})
|
||||
}
|
||||
module.exports = startMongoDB
|
||||
Reference in New Issue
Block a user