- Node.js 6.x Blueprints
- Fernando Monteiro
- 248字
- 2021-07-14 10:35:05
Installing and configuring Sequelize-cli
Sequelize-cli is a very useful command-line interface for creating models, configurations and migration files to databases. It's integrated with Sequelize middleware and operates with many relational databases such as PostgreSQL, MySQL, MSSQL, Sqlite.
Tip
You can find more information about Sequelize middleware implementation at: http://docs.sequelizejs.com/en/latest/ and full documentation of Sequelize-Cli at: https://github.com/sequelize/cli.
- Open terminal/shell and type:
npm install -g sequelize-cli
- Install
sequelize
with the following command:npm install sequelize -save
Tip
Remember we always use the
-save
flag to add the module to ourpackage.json
file. - Create a file called
.sequelizerc
on the root folder and place the following code:var path = require('path'); module.exports = { 'config': path.resolve('./config', 'config.json'), 'migrations-path': path.resolve('./config', 'migrations'), 'models-path': path.resolve('./', 'models'), 'seeders-path': path.resolve('./config', 'seeders') }
- On terminal/shell, type the following command:
sequelize init
- After the
init
command, the terminal will show the following output message:Sequelize [Node: 6.3.0, CLI: 2.3.1, ORM: 3.19.3] Using gulpfile /usr/local/lib/node_modules/sequelize -cli/lib/gulpfile.js Starting 'init:config'... Created "config/config.json" Finished 'init:config' after 4.05 ms Successfully created migrations folder at "/chapter-02/config /migrations". Finished 'init:migrations' after 1.42 ms Successfully created seeders folder at "/chapter-02/config /seeders". Finished 'init:seeders' after 712 ??s Successfully created models folder at "/chapter-02/models". Loaded configuration file "config/config.json". Using environment "development". Finished 'init:models' after 18 msStarting 'init'...
This command also creates the models directory to store application schema, a configuration file, and folders to hold seeders and the migrations script. Don't worry about this now, we will look at migrations in the next section.
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- Mastering Swift 2
- Visual Basic程序設計與應用實踐教程
- The Data Visualization Workshop
- Learning AndEngine
- INSTANT Mercurial SCM Essentials How-to
- Python Data Analysis(Second Edition)
- Yocto for Raspberry Pi
- 劍指MySQL:架構、調優與運維
- Learning Modular Java Programming
- JavaScript應用開發實踐指南
- 機器學習微積分一本通(Python版)
- Android應用開發深入學習實錄
- 算法設計與分析:基于C++編程語言的描述
- 超簡單:Photoshop+JavaScript+Python智能修圖與圖像自動化處理