Naive Puppets Marching

    sails-mysql-autogen

    2.0.2 • Public • Published

    Sails Mysql AutoGen

    Generate models automatically for Sails Js or Waterline for Mysql connections

    Version 2.0.0

    One bad thing when you work with sails js is do all the models by hand... until now, this generator helps to do this task in a very simple way.

    The usage of this generator is a bite simple.

    #npm i sails-mysql-autogen -g 

    Sails Mysql AutoGen will prompt connection for usage.... and thats all, it will generate all files for represent you database, in the current directory.

    Data Types

    Automodel support all data types present in waterline:

    • string
    • text
    • integer
    • float
    • date
    • time
    • datetime
    • boolean
    • binary
    • array
    • json

    Associations

    At this version AutoModel can detect all foreign keys only as model attribute, if in your associations you need the virtual attribute collections you must create by your self, but half way is taken by AutoModel, in the next releases i will try to give the power to AutoModel to handle complete associations.

    AutoModel in action

    Example model

    Models generated by AutoModel

    Model Pets
    module.exports = {
        "identity": "Pets",
        "connection": "sails_test",
        "autoCreatedAt": false,
        "autoUpdatedAt": false,
        "attributes": {
            "id": {
                "type": "INTEGER",
                "primaryKey": "TRUE",
                "autoIncrement": "TRUE"
            },
            "name": "STRING",
            "Owners": {
                "model": "Owners",
                "columnName": "owner_id"
            }
        }
    }
    
    Model Owners
    module.exports = {
        "identity": "Owners",
        "connection": "sails_test",
        "autoCreatedAt": false,
        "autoUpdatedAt": false,
        "attributes": {
            "id": {
                "type": "INTEGER",
                "primaryKey": "TRUE",
                "autoIncrement": "TRUE"
            },
            "name": "STRING",
            "lastname": "STRING",
            "email": "STRING"
        }
    }
    

    As you can see automodel helps a lot with the tedious task of creating the models.

    I hope AutoModel helps to make all of your models as an easy task, as well for me.

    To-do

    • Detect Sails connections automatically

    Install

    npm i sails-mysql-autogen

    DownloadsWeekly Downloads

    6

    Version

    2.0.2

    License

    MIT

    Last publish

    Collaborators

    • cadrogui