Skip to content

Oteng/sails-sql-converter-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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',
        }
    };
   */

About

Converts an SQL schema to a valid sails model preserving all relationships

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published