0.1.4 • Published 9 years ago
sails-sql-converter-cli v0.1.4
#sails-sql-converter-cli
###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 -gMicrosoft Windows
$ npm install sails-sql-converter-cli -gUsage
$ sails-sql -f newdb.sqlOptions
-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 fileSupported SQL Keywords
Table
Create
Primary Key
Foreign Key
ReferencesData 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 -> binaryExample
$ 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',
}
};
*/