All Projects → juliandavidmr → sails-inverse-model

juliandavidmr / sails-inverse-model

Licence: MIT license
Generate views, models and controllers for SailsJS from MySQL, PostgreSQL and MongoDB

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to sails-inverse-model

sails-hook-multitenant
A multitenant Sails.js 1.X hook for Waterline ORM.
Stars: ✭ 15 (-70.59%)
Mutual labels:  sailsjs, waterline
wasteof.money
next-gen social media. this repo is for wasteof.money legacy which is no longer online. the new site is built with nuxt.js on the frontend and is currently not open source.
Stars: ✭ 31 (-39.22%)
Mutual labels:  ejs
sails-jwt-login
How to implement login with JWT (JSON Web Tokens) in Sails 1.0
Stars: ✭ 18 (-64.71%)
Mutual labels:  sailsjs
HIMS
Hospital Information Management System create using Node Js
Stars: ✭ 41 (-19.61%)
Mutual labels:  ejs
angular2-sails
An angular module for using the sails socket.io api in angular2 (@angular)
Stars: ✭ 37 (-27.45%)
Mutual labels:  sailsjs
TradeByte
💸 TradeByte - Stocks Trading Simulation WebApp
Stars: ✭ 30 (-41.18%)
Mutual labels:  ejs
Sinn Server
an node server for sinn,that based on of nodejs,koa2,mongoose,docker,nginx,es6/7,Resful API,阿里云 http://servertest.boyagirl.com/
Stars: ✭ 228 (+347.06%)
Mutual labels:  ejs
bowman
A simple static site generator with an integrated toolchain for efficient development and delivery.
Stars: ✭ 17 (-66.67%)
Mutual labels:  ejs
atomic-lab
Styleguide Generator based on partial templates ( html / ejs / haml )
Stars: ✭ 41 (-19.61%)
Mutual labels:  ejs
hyouka
Um bot open-source com dashboard incluída
Stars: ✭ 12 (-76.47%)
Mutual labels:  ejs
Awesome Cheatsheets
👩‍💻👨‍💻 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.
Stars: ✭ 26,007 (+50894.12%)
Mutual labels:  sailsjs
express-mvc
A light-weight mvc pattern for express framework with minimum dependencies
Stars: ✭ 23 (-54.9%)
Mutual labels:  sailsjs
WebAppReader
基于 html5 、 Vue.js 、 Koa、Node.js 以及 EJS 的手机小说阅读器。使用 node.js 模拟后台数据,无实际后台,完全的前后端分离开发。
Stars: ✭ 15 (-70.59%)
Mutual labels:  ejs
douMiBlog-Sailsjs
豆米博客-Sailsjs版,个人博客系统,使用SailsJs,MongoDb,Bootstrap,marked,SASS,swig等
Stars: ✭ 22 (-56.86%)
Mutual labels:  sailsjs
sails-token-auth-setup
Token based authentication installation guide
Stars: ✭ 24 (-52.94%)
Mutual labels:  sailsjs
Express Ejs Layouts
Layout support for ejs in express.
Stars: ✭ 243 (+376.47%)
Mutual labels:  ejs
ytmous
Anonymous Youtube Proxy
Stars: ✭ 60 (+17.65%)
Mutual labels:  ejs
Skeleton-EJS
A front-end template build upon Rosid.
Stars: ✭ 13 (-74.51%)
Mutual labels:  ejs
sails-hook-swagger-generator
A tool to help generate Swagger specification documentation based on OAS 3.0 for Sails APIs
Stars: ✭ 71 (+39.22%)
Mutual labels:  sailsjs
micro-template.js
A template engine on JavaScript which like embed js
Stars: ✭ 49 (-3.92%)
Mutual labels:  ejs

enter image description here

Automated generator models, views and controllers for SailsJS & WaterLine

Build Status

Sails Inverse Model helps you build models, controllers and views JS Sails from any database. In addition, you can quickly and individually generate each model, view, controller or all three at the same time.

Available for PostgreSQL, MySQL and MongoDB


Installation

Linux or MacOS

$ sudo npm install sails-inverse-model@next -g

Microsoft Windows

$ npm install sails-inverse-model@next -g

Individual generation

You can quickly generate a model, a controller, a view or these three at the same time simply define the attributes of your model. Let's look at an example:

# Generate model
$ sails-inverse-model -g model --name Pet -a "name:string:r:u owner:string"

# Generate Controller
$ sails-inverse-model -g controller --name Pet -a ""

# Generate View
$ sails-inverse-model -g view --name Pet -a "name:string:r owner:string"

# Generate all (Model, View and Controller)
$ sails-inverse-model -g all --name Pet -a "name:string:r:k owner:string"

Detail

Param Description
g Generate view, model, controller
name Name: model, driver, and view folder
a Content of the element to generate
name:string:params Attribute name: data type: params

Specifies the type of data that will be stored in this attribute. Here

Params

Param Description Example
r Required catname:string:r
u Unique catname:string:u
a Autoincrement index:integer:a
k Primary Key index:integer:k

You can also set all three parameters at the same time, for example: index:integer🅰️u:r

Example

sails-inverse-model -g model --name Pet -a "index:integer:r:u:a name:string:r:u owner:string:r"

=>
  module.exports = {
      attributes: {
          index: {                -> index
              type: 'integer',    -> :integer 
              required: true,     -> :r
              unique: true,       -> :u 
              autoincrement: true -> :a
          },
          name: {
              type: 'string',
              required: true,
              unique: true
          },
          owner: {
              type: 'string',
              required: true
          }
      }
  };

Generator (from Database)

$ sails-inverse-model --help

  Sails Inverse Model helps you build models, controllers and views JS Sails from any database. In addition, you can quickly and individually generate each model, view, controller or all three at the same time.

                  .-..-.														      
																	
  Sails-inverse-model<|    .-..-.	2.x.x
                      |										
      ~    ~   ~     /|. 									
         ~  ~       / || 									
           ~  ~   ,'  |'  									
               .-'.-==|/_--'								
               `--'-------' 								
     _--__--_---__---___--__---__--___      
   __---__--__---___--__---___--_-_---___    
   ----------------------------------------------------------
   :: Sat Feb 04 2017 22:43:52 GMT-0500 (COT)
   ----------------------------------------------------------
  Example:
    $ mkdir sails-output
    $ cd sails-output
    $ sails-inverse-model -u postgres -p root -d almacen -t pg -m -v -c

  User         : postgres
  Password     : root
  Database     : almacen
  Host         : localhost
  Models       : /home/julian/Documents/sails-output/models
  Views        : /home/julian/Documents/sails-output/views
  Controllers  : /home/julian/Documents/sails-output/controllers
  DB           : pg
  Schema (pg)  : public
  =====================================
  Views [OK]
  =====================================
  Models [OK]
  =====================================
  Controllers [OK]

      Note: Copy models      => your/project_sails/api
            Copy controllers => your/project_sails/api
            Copy views/*     => your/project_sails/views/
   Then: 
   $ cd your/project_sails/
   $ sails lift

   More info: https://github.com/juliandavidmr/sails-inverse-model
   ---------------------------------------------------------------
  Options:
   -u, --user        User of database
   -p, --pass        Password of database
   -d, --database    Database name
   -h, --host        Host server               Default: localhost
   -m, --models      Folder output models      Default: Folder actual
   -c, --controllers Folder output controllers Default: Folder actual
   -v, --views       Folder output views       Default: Folder actual (Experimental)
   -t, --type        Type gestor database: mysql|postgres|mongodb  Default: mysql
   -s, --schema      (Only PostgreSQL) Schema database postgres: Default: public
   -f, --file        (Only MySQL) .sql file path entry (Experimental)


  ====================== Individual generation ==================
  You can quickly generate a model, a controller, a view or these three at the same time.
  # Generate model
  $ sails-inverse-model -g model --name Pet -a "name:string:r:u owner:string"

  # Generate Controller
  $ sails-inverse-model -g controller --name Pet -a "name:string:r:u owner:string"

  # Generate View
  $ sails-inverse-model -g view --name Pet -a "name:string:r owner:string"

  # Generate all (Model, View and Controller)
  $ sails-inverse-model -g all --name Pet -a "name:string:r:k owner:string"

  Where:
  --------------------------------------------
  |Param | Description   |     Example       |
  |------|---------------|-------------------|
  |   r  | Required      | catname:string:r  |
  |   u  | Unique        | catname:string:u  |
  |   a  | Autoincrement | index:integer:a   |
  |   k  | Primary Key   | index:integer:k   |
  --------------------------------------------
  You can also set all three parameters at the same time, for example: index:integer:a:u:r

MySQL

sails-inverse-model -u root -p root -d mydbmysql -m -v -c

MySQL from file .sql

sails-inverse-model -f /your/path/to/script.sql -m -v -c

PostgreSQL

sails-inverse-model -u postgres -p root -d almacen -t pg -m -v -c

MongoDB

sails-inverse-model -d blog_db -t mg -m -v -c

Import

Install package

npm install sails-inverse-model --save

Generate from MySQL

var sim = require('sails-inverse-model');

var config = {
  host: "localhost",
  database: "almacen",
  user: "root",
  pass: "root",
  port: 3306
}

var folder_controllers = "/your/project/sails/api/"; //if folder_models == "" then: no generate controllers
var folder_models = "/your/project/sails/api/"; //if folder_models == "" then: no generate models
var folder_views = "/your/project/sails/"; //if folder_models == "" then: no generate views

sim.generatemy(config, folder_models, folder_controllers, folder_views, plurallang);

Generate from PostgreSQL

var sim = require('sails-inverse-model');

var config = {
  host: "localhost",
  database: "example",
  user: "postgres",
  pass: "root",
  port: 5432,
  schema: "public"
}

var folder_controllers = "/your/project/sails/api/"; //if folder_models == "" then: no generate controllers
var folder_models = "/your/project/sails/api/"; //if folder_models == "" then: no generate models
var folder_views = "/your/project/sails/"; //if folder_models == "" then: no generate views

sim.generatepg(config, folder_models, folder_controllers, folder_views, plurallang);

Generate from MongoDB

var sim = require('sails-inverse-model');

var folder_controllers = "/your/project/sails/api/"; //if folder_models == "" then: no generate controllers
var folder_models = "/your/project/sails/api/"; //if folder_models == "" then: no generate models
var folder_views = "/your/project/sails/"; //if folder_models == "" then: no generate views

//                host       port         database           views         models        controllers
sim.generatemg('localhost', 27017, 'my_name_collection', folder_views, folder_models, folder_controllers);

Then navigate to the output folder and can find the js generated.

Contributions

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].