后台:增加后台数据库表,修复连接问题
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user