-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (33 loc) · 882 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { Sequelize, DataTypes, Model } = require('sequelize')
const sequelize = new Sequelize({
username: 'root',
password: 'BHU*nji9',
database: 'contatos',
dialect: 'sqlite',
storage: 'database.sqlite'
})
sequelize.authenticate()
.then(() => {
console.log('OK')
}).catch( error => {
console.log(error)
})
class User extends Model{}
User.init({
nome: { type: DataTypes.STRING },
email: { type: DataTypes.STRING},
telefone: { type: DataTypes.STRING},
dataNascimento: { type: DataTypes.DATEONLY}
},
{sequelize}
)
// sequelize.sync()
// .then(() => console.log('OK'))
// .catch( error => console.log(error));
User.create( {
name: 'xpto',
email: 'xpto@gmail.com',
telefone: '(99) 99999-9999',
dataNascimento: '2020-01-01'
}).then( console.log('SALVOU'))
.catch( error => console.log(error))