Socket
Socket
Sign inDemoInstall

sails-mysql-autogen

Package Overview
Dependencies
29
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sails-mysql-autogen

Create models for Sails Js - Waterline


Version published
Weekly downloads
5
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 21 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc