chore: load dataSource after start

This commit is contained in:
Chareice 2024-01-25 21:16:28 +08:00
parent ec52a82ff0
commit c7c0208c4a
No known key found for this signature in database

View File

@ -162,28 +162,26 @@ export class PluginDataSourceManagerServer extends Plugin {
}); });
this.app.on('afterStart', async (app: Application) => { this.app.on('afterStart', async (app: Application) => {
const databaseConnections: DatabaseConnectionModel[] = await this.app.db const dataSourcesRecords: DataSourceModel[] = await this.app.db.getRepository('dataSources').find();
.getRepository('databaseConnections') for (const dataSourceRecord of dataSourcesRecords) {
.find(); await dataSourceRecord.loadIntoApplication({
// load all connections
for (const databaseConnection of databaseConnections) {
await databaseConnection.loadIntoApplication({
app, app,
}); });
} }
});
this.app.on('afterStart', async (app: Application) => {
// load roles // load roles
const rolesModel: ConnectionsRolesModel[] = await this.app.db.getRepository('connectionsRoles').find(); // const rolesModel: ConnectionsRolesModel[] = await this.app.db.getRepository('connectionsRoles').find();
const pluginACL: any = this.app.pm.get('acl'); // const pluginACL: any = this.app.pm.get('acl');
//
for (const roleModel of rolesModel) { // for (const roleModel of rolesModel) {
await roleModel.writeToAcl({ // await roleModel.writeToAcl({
grantHelper: pluginACL.grantHelper, // grantHelper: pluginACL.grantHelper,
associationFieldsActions: pluginACL.associationFieldsActions, // associationFieldsActions: pluginACL.associationFieldsActions,
acl: this.app.acls.get(roleModel.get('connectionName')), // acl: this.app.acls.get(roleModel.get('connectionName')),
}); // });
} // }
}); });
this.app.db.on('connectionsRolesResources.afterSaveWithAssociations', async (model, options) => { this.app.db.on('connectionsRolesResources.afterSaveWithAssociations', async (model, options) => {