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 as Command } from './command.js'
|
||||||
|
|
||||||
export default async function connectDB(uri) {
|
export default async function connectDB(uri) {
|
||||||
try {
|
const db = await mongoose.connect(uri, {
|
||||||
const db = await mongoose.connect(uri, {
|
useNewUrlParser: true,
|
||||||
useNewUrlParser: true,
|
useUnifiedTopology: true,
|
||||||
useUnifiedTopology: true,
|
})
|
||||||
})
|
return db.connection.getClient()
|
||||||
return db.connection.getClient()
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
throw new Error('Failed to connect to MongoDB')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user