sails-sql-converter-cli

0.1.4 • Public • Published

#sails-sql-converter-cli enter image description here Build Status ###Description: This is a command line tool for generating sails models from sql scheme. Design your database using any UML software you want export your design to sql and use this tool to generate sails models.

Installation

Linux or MacOS

$ npm install sails-sql-converter-cli -g

Microsoft Windows

$ npm install sails-sql-converter-cli -g

Usage

$ sails-sql -f newdb.sql

Options

-h --help : show a help massage
-o --out  : specify where the generated files should be saved.
            Defaults to the location where the command is runned
-f --file : specify the sql file

Supported SQL Keywords

Table
Create
Primary Key
Foreign Key
References

Data Types Mapping

varchar, char, tinyblob, tinytext           -> string
int, smallint, tinyint, mediumint, bigint   -> interger
float, double, decimal                      -> float
blob, text                                  -> text
mediumblob, mediumtext                      -> mediumtext
longblob, longtext                          -> longtext
date                                        -> date
datetime, timestamp                         -> datetime
binary                                      -> binary

Example

    $ cat user.sql
   /*
    CREATE TABLE IF NOT EXISTS `mydb`.`User` (
      `user_id` INT NOT NULL,
      `username` VARCHAR(45) NULL,
      `password` VARCHAR(45) NULL,
      `type` VARCHAR(45) NULL,
      PRIMARY KEY (`user_id`))
   */

$ sails-sql -f user.sql

   /*
    User.js

    module.exports = {
        attributes: {
            username: 'string',
            password: 'string',
            type: 'string',
        }
    };
   */

Package Sidebar

Install

npm i sails-sql-converter-cli

Weekly Downloads

0

Version

0.1.4

License

MIT

Last publish

Collaborators

  • spirit