https://github.com/davidep87/koa-sequelize
koa sequelize boilerplate
https://github.com/davidep87/koa-sequelize
koa nodejs sequelize
Last synced: 19 days ago
JSON representation
koa sequelize boilerplate
- Host: GitHub
- URL: https://github.com/davidep87/koa-sequelize
- Owner: davidep87
- Created: 2017-07-02T18:46:14.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T16:30:22.000Z (about 5 years ago)
- Last Synced: 2025-03-31T03:41:27.971Z (about 2 months ago)
- Topics: koa, nodejs, sequelize
- Language: JavaScript
- Size: 9.77 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### Node.JS (7.7.1) - KoaJS (2.3) - Sequelize 3.3
#### Before you start the project you have to install the database dialect based on your preference:
`$ npm install --save pg pg-hstore`
`$ npm install --save mysql2`
`$ npm install --save sqlite3`
`$ npm install --save tedious // MSSQL`
###### or
`$ yarn add pg pg-hstore``$ yarn add mysql2`
`$ yarn add sqlite3`
`$ yarn add tedious // MSSQL`
- ###### Then configure the file database.js in the config directory
- ###### Create e .env file with this variables:
- LOCAL_HOST
- PRODUCTION_HOST
- STAGING_HOST
- SECRET_KEY
- PORT
- DB_USER
- DB_PASSWORD
- DATABASE
- DB_HOST- ###### In models you can find a ready to use example of Users model
##### How to modify database structure without forcing sync of sequelize:
- Create a migration file running this command example in the main dir of the project:
- `$ sequelize migration:create --name "nameOfMigrationFile" --migrations-path migrations/`
- Write logic to change db structure in the new generated file in migrations/
- Documentation: http://docs.sequelizejs.com/en/latest/docs/migrations/
- Run the command sequelize db:migrate to update database structure##### NOTE: database models are attached on the koa context so you are able to use it easily around the project like:
`cont users = await ctx.db.models.User.findAll()`
###### This project is not ready for production is just a good starting point to approach sequelize and koa
## Author
[Davide Polano](https://www.mdslab.org)