What is Tiny-Models ?
- Simple - Tiny Models it's a module that will help you save a lot of time in your process of creating models for your project
- Automatic - Tiny-Models will read all the modules you have created in an specific folder in order to create the sequelize model associated.
Important : The name of the models will be the name of the model file - Clear - The definition of the modules is really clear and this is the force of Tiny-Models. The models are finally just a Javascript object which makes the creation of models really simple and clear.
Installation
npm install tiny-models-sequelize
models/Users.js
Sample model This file will give you a taste of what Tiny-Models does. The name of the model, will be : Users
var Seq = ; //Creating our modulemoduleexports = model: first_name: type : SeqSTRING last_name: type : SeqSTRING mail: type : SeqSTRING password: type : SeqSTRING options : instanceMethods : { var ret = cypter return ret; }
Initialize Tiny-Models
Here you learn how to initialize the module. For that you have to give the path where your models are defined and the configuration of the database.
var tmS = ; tmS;
database.json
Sample You can call this file as you like
"development": "database": "YourBDD" "dialect": "mysql" "host": "127.0.0.1" "username": "root" "password": ""
Use a model
When you have defined your model, you will be able to use it really easily, and of course have access to all the sequelize methods.
See Sequelize doc
var tmS = ; { var Users = tmS; Users }
If you have any questions or feedbacks, feel free to contact me at : levacher.alex@gmail.com
This module was developed for Luncher.fr
This module is inspired by a Jeysson Guevara article