const Automate = require('sequelize-automate-freesun') async function handleTask(app, task) { try { const { models } = app.fs.dc const dataSource = await models.DataSource.findOne({ where: { id: task.dataSourceId } }); if (dataSource) { const dbOptions = createDbOptions(dataSource.config); const automate = new Automate(dbOptions, {}); const tables = await automate.getTables() console.log(tables) } } catch (error) { app.fs.logger.error(`sechedule: handleTask, error: ${error}`); } } function createDbOptions(params) { const dbOptions = { database: params.database, username: params.user, password: params.password, dialect: 'postgres', host: params.host, port: params.port, define: { underscored: false, freezeTableName: false, charset: 'utf8mb4', timezone: '+00: 00', dialectOptions: { collate: 'utf8_general_ci', }, timestamps: false, }, } return dbOptions } module.exports = { handleTask }