Skip to content

Instantly share code, notes, and snippets.

@championswimmer
Last active January 19, 2018 22:51
Show Gist options
  • Save championswimmer/8186d080e7d0a23854112aefbca6021d to your computer and use it in GitHub Desktop.
Save championswimmer/8186d080e7d0a23854112aefbca6021d to your computer and use it in GitHub Desktop.
const Sequelize = require('sequelize')
const db = new Sequelize('db', 'user', 'pass', {
dialect: 'postgres'
})
const User = db.define('users', {
// line A
name: Sequelize.STRING,
age: Sequelize.INTEGER,
city: Sequelize.STRING,
isAdmin: {type: Sequelize.BOOLEAN, defaultValue: false}
})
db.sync().then(() => {
User.create({
// line B
name: 'Arnav', age: 23, city: 'Delhi', isAdmin: true
}).then(user => {
// line C
console.log(user.age) // 23
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment