后台:增加后台数据库表,修复连接问题

This commit is contained in:
luying
2021-11-23 13:34:53 +08:00
parent 7940e6d09d
commit f69ac140fb
14 changed files with 84 additions and 39 deletions

View File

@@ -48,18 +48,28 @@ export default class FooBoot implements IBoot {
public async connectDB(app: Application) {
const { url, options } = app.config.mongoose
if (url) {
const connection = await mongoose.connect(url, options)
app.context.connection = connection
try {
if (url) {
const connection = await mongoose.connect(url, options)
console.log('******connectDB suc', url, options)
app.context.connection = connection
}
} catch(e) {
console.log(e)
}
}
public async connectGMDB(app: Application) {
const { url, options } = app.config.gmmongoose
if (url) {
const connection = await mongoose.createConnection(url, options)
app.context.connectionGM = connection;
loadGmDb(connection);
try {
if (url) {
const connection = await mongoose.createConnection(url, options)
app.context.connectionGM = connection;
loadGmDb(connection);
console.log('******connectGMDB suc', url, options)
}
} catch(e) {
console.log(e)
}
}