Sitelet https://web.archive.org/web/20210116023123/https://github.com/masfranzhuo/sequalize-express-SQLite
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Build Status

Node.js sequelize express CRUD

Node.js CRUD application based on the SQLite database design and Express.js framework

This Node.js CRUD code use

  • Express.js framework
  • SQLite database
  • sequelize ORM
  • dotenv module for setting environment
npm init

npm install --save express sqlite3 sequelize body-parser

npm install --save dotenv

Database

The application connect to SQLite database using sequalize. The configuration of database added in models/index.js. Create folder data on the root project for SQLite storage path.

var sequelize = new Sequelize('example', 'root', '', {
    host: 'localhost',
    dialect: 'sqlite',
    operatorsAliases: false,
    // SQLite database path
    storage: './data/database.sqlite'
});

Initialize the configuration and connect to database on app.js.

var models = require("./models");

models.sequelize.sync().then(function() {
    console.log('connected to database')
}).catch(function(err) {
    console.log(err)
});

This app use database named example and books table which has 4 columns.

Route

Create routes folder on the root path and put route file there. After that initialiaze and register route file path on app.js file.

var books = require('./routes/books');

app.use('/books', books);

Documentation

This API documented with Swagger and hosted on Heroku

You can’t perform that action at this time.