This repository demonstrates the usage of Sequelize within an Express application. The implemented logic is a simple task tracking tool.
Without Migrations
npm install
npm start
With Migrations
npm install
node_modules/.bin/sequelize db:migrate
npm start
This will start the application and create an sqlite database in your app dir. Just open http://localhost:3000.
We have added some Mocha based test. You can run them by npm test
In order to understand how this application has been built, you can find the executed steps in the following snippet. You should be able to adjust those steps according to your needs. Please note that the view and the routes aren't described. You can find those files in the repo.
First we will create a bare Express App using express-generator
Express Generator
# install express generator globally
npm install -g express-generator
# create the sample app
express express-example
cd express-example
# install all node modules
npm install
Now we will install all sequelize related modules.
# install ORM , CLI and SQLite dialect
npm install sequelize sequelize-cli sqlite3
# generate models
node_modules/.bin/sequelize init
node_modules/.bin/sequelize model:create --name User --attributes username:string
node_modules/.bin/sequelize model:create --name Task --attributes title:string