Giter Club home page Giter Club logo

ms2sm's Introduction

M2MS

a simple tool to convert mysql Schema to sails model json file

Just hate to write the model json by hand so write this ##Options

$ node m2sm.js --help
  Usage: m2sm.js [options]
  Options:
    -h, --help                      output usage information
    -V, --version                   output the version number
    -h, --host [host addr]          Specify mysql host,default is localhost
    -d, --database [database name]  Specify database name
    -t, --table [table]             Specify table name
    -u, --user [user name]          Specify user name defualt is root
    -p, --password [password]       Specify password defualt empty

##Example

mysql> desc bus_vehicles;
+----------------+------------------+------+-----+---------+-------+
| Field          | Type             | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------+-------+
| Vehicle_ID     | int(20) unsigned | NO   | PRI | NULL    |       |
| License_Number | varchar(32)      | YES  |     | NULL    |       |
| Device_ID      | varchar(64)      | YES  |     | NULL    |       |
| Route_Name     | varchar(64)      | YES  |     | NULL    |       |
| createdAt      | datetime         | YES  |     | NULL    |       |
| updatedAt      | datetime         | YES  |     | NULL    |       |
+----------------+------------------+------+-----+---------+-------+
6 rows in set (0.04 sec)

we will get the sails model json like below

$ node m2sm --database db_name --table bus_vehicles -u yourname -p secret

then

{ schema: true,
  attributes:
   { Vehicle_ID: { type: 'integer', primaryKey: true },
     License_Number: { type: 'string' },
     Device_ID: { type: 'string' },
     Route_Name: { type: 'string' } },
  tableName: 'bus_vehicles' }

##Bugs It just fit my requirement. If shit happens, leave me a issue or pull request your code

ms2sm's People

Contributors

stormslowly avatar dan-power avatar

Stargazers

Muh Isfhani Ghiath avatar  avatar Tobias Toland avatar Evgeni Atanasov avatar Leo Liu avatar Terry avatar Anton Petrov avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.