Code for my Sequelize 101 talk.
Hello, and welcome! This tutorial covers the basics of CRUD operations and simple examples using the Node ORM Sequelize. We will use Express.js to build out an API, but the focus here is Sequelize. I will assume you have PostgreSQL installed on your machine, and that you're using Node version ^8.10
- Built with Node.js and Express
Route | HTTP Verb | Description |
---|---|---|
/api/users | GET | Get list of users |
/api/users | POST | Creates a new user |
/api/users/:id | GET | Get a single user |
/api/users/:id | DELETE | Deletes a user |
/api/users/me | GET | Get my info |
- Run
npm install
to install server dependencies. - Run
npm run dev
to start the development server and sync db - After the terminal shows:
info: Express server listening on 3000, in development mode
stop the demon
# Move to example folder
$ cd examples
# Fill the database with the sample data
$ node seed.js
# Run any of the examples
node 1.js
node sum.js
If you want to do the workshop, in the repo wiki you can find it.
- Run
npm install
to install server dependencies. - Run
npm run dev
to start the development server. - Open a new tab of the terminal and run:
node example/seed.js
- Open browser
http://localhost:3000/api/users
.
Cristian Moreno - FullStack Javascript Developer