fix: rethrowing connectDB error

This commit is contained in:
wancat committed 2023-10-14 15:54:56 +08:00
1 parent 46071d8830
commit 08eaa550a0
1 file changed
-5
-5
View File
@@ -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')
}
} }