Created
October 24, 2018 17:58
-
-
Save danicuki/0b931cb3c5d2998e21156265f5e77aef to your computer and use it in GitHub Desktop.
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
# bash | |
mkdir nova-pasta | |
npm init | |
npm install --save sequelize | |
npm install --save sequelize-cli | |
npm install --save sqlite3 | |
npm install --save mysql2 | |
sequelize init | |
sequelize model:generate --name Book --attributes title:string,pages:integer | |
sequelize db:migrate | |
sequelize model:generate --name Book --attributes title:string,pages:integer | |
sequelize db:migrate | |
# A partir daqui é node | |
> const db = require("./models/index.js"); | |
> db.Author.create({name: "JK Rolling"}) | |
> db.Author.findById(2).then(a => console.log(a.name)); | |
// alterando 1 | |
> db.Author.findById(2).then(a => { | |
a.cpf = "12345123" | |
a.save() | |
}); | |
//alterando 2 | |
> db.Author.findById(2).then(a => a.update({cpf: "abcd"})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment