Skip to content

Instantly share code, notes, and snippets.

@akvsh-r
Forked from loic-moriame/index.js
Created April 11, 2018 20:30
Show Gist options
  • Save akvsh-r/a5ce887db04e3c23ba76b1de563eef39 to your computer and use it in GitHub Desktop.
Save akvsh-r/a5ce887db04e3c23ba76b1de563eef39 to your computer and use it in GitHub Desktop.
node.js + sequelize + sqlite
'use strict';
var Sequelize = require('sequelize');
var sequelize = new Sequelize('mainDB', null, null, {
dialect: "sqlite",
storage: './test.sqlite',
});
sequelize
.authenticate()
.then(function(err) {
console.log('Connection has been established successfully.');
}, function (err) {
console.log('Unable to connect to the database:', err);
});
// MODELS
var User = sequelize.define('User', {
username: Sequelize.STRING,
password: Sequelize.STRING
});
// SYNC SCHEMA
sequelize
.sync({ force: true })
.then(function(err) {
console.log('It worked!');
}, function (err) {
console.log('An error occurred while creating the table:', err);
});
{
"main": "index.js",
"dependencies": {
"sequelize": "^3.4.1",
"sqlite3": "^3.0.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment