Skip to content

Instantly share code, notes, and snippets.

@haidarafif0809
Last active February 21, 2018 10:50
Show Gist options
  • Save haidarafif0809/ac3a18a617301c2e93f619bdb05e3862 to your computer and use it in GitHub Desktop.
Save haidarafif0809/ac3a18a617301c2e93f619bdb05e3862 to your computer and use it in GitHub Desktop.
Sequelize Example
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'mysql'|'sqlite'|'postgres'|'mssql',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
// SQLite only
storage: 'path/to/database.sqlite',
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
operatorsAliases: false
});
const User = sequelize.define('user', {
username: Sequelize.STRING,
birthday: Sequelize.DATE
});
sequelize.sync()
.then(() => User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20)
}))
.then(jane => {
console.log(jane.toJSON());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment