mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
fix: rethrowing connectDB error
This commit is contained in:
1 parent
46071d8830
commit
08eaa550a0
1 file changed
+5
-10
@@ -6,14 +6,9 @@ export { default as Session } from './session.js'
|
||||
export { default as Command } from './command.js'
|
||||
|
||||
export default async function connectDB(uri) {
|
||||
try {
|
||||
const db = await mongoose.connect(uri, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
})
|
||||
return db.connection.getClient()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
throw new Error('Failed to connect to MongoDB')
|
||||
}
|
||||
const db = await mongoose.connect(uri, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
})
|
||||
return db.connection.getClient()
|
||||
}
|
||||
Reference in new issue
Block a user