Skip to content

lbarcenasvisp/Models-Generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Models-Generator

A cli tool for generating sequelize models from a mysql database with the following code format:

import Sequelize from 'sequelize'
import {db} from '~/data/sequelize_connection'
db.define('aaatest', {
    field_1: {
        type:  Sequelize.INTEGER(11),
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
        ...
    },
    ...
})
const tablenameModel = db.models.tablename;
export {tablenameModel};
  • db : A sequelize instance containing the mysql database credentials for your project
  • tablename : Table name from your mysql database

Installing

Must have installed mysql globally

$ npm install -g models-generator-2

Usage

Go to your project's root working directory. Write in the terminal the following command.

$ generate -o FOLDER_NAME -d DB_NAME -h HOST -u USERNAME -p PORT -x PASS

Future Plans

  • Add output formatter, contrary to the current default format
  • Ability to choose a single file for generating

About

A cli tool for generating sequelize models from a mysql database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%