dbml2sequelize

1.0.4 • Public • Published

dbml2sequelize

converts dbml to sequelize model

const path = require("path");
const Sequelize = require("sequelize");
const { default: SequelizeAuto } = require("sequelize-auto");
const parseDbml = require("dbml2sequelize");

const opts = {
  dialect: "postgres",
  host: "localhost",
  port: 5432,
};
const sequelize = new Sequelize("micro", "admin", "password", opts);

parseDbml(sequelize, Sequelize.DataTypes, path.join(__dirname, "./db.dbml"), {
  timestamps: true,
  createdAt: "created_dt",
  updatedAt: "modified_dt",
});

sequelize.sync({ force: true }).then(() => {
  console.log("done");

  const auto = new SequelizeAuto(sequelize, null, null, {
    ...opts,
    directory: path.join(__dirname, "typed-models"),
    lang: "ts",
    caseModel: "p",
    caseFile: "p",
  });

  auto.run().then(() => {
    console.log("done");
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i dbml2sequelize

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

17.7 kB

Total Files

17

Last publish

Collaborators

  • cedrickcampoto