UNPKG

sequelize-ts-boilerplate

Version:

A REST API scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema design

29 lines (24 loc) 917 B
import SequelizeAuto = require("sequelize-auto"); import { IConfig } from "../../interfaces/config"; class SequelizeAutoService { public getTables = (config: IConfig) => { const conn = config.DATABASE_CONNECTION_SETINGS[config.ENV]; return new Promise((resolve, reject) => { const auto = new SequelizeAuto(conn.db, conn.username, conn.password, { host: conn.host, dialect: conn.dialect, directory: false, port: conn.port, // options: { // encrypt:false // } }); console.log("running db query..."); auto.run( (err) => { if (err) throw new Error(err); resolve(auto.tables); }) }) } } export default new SequelizeAutoService();