Created
September 11, 2017 23:42
-
-
Save vincentdesmares/a91def2be99693edc32dc45a9dc7d77f to your computer and use it in GitHub Desktop.
A very simple example of how Sequelize works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sequelize = require('sequelize'); | |
const sequelize = new Sequelize('database', 'username', 'password'); | |
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.get({ | |
plain: true | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment