forked from jtarasova/sequelize_intro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (38 loc) · 1.1 KB
/
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
// console.log('hello');
const db = require('./db/models');
const {
Sequelize: { Op },
User,
sequelize,
} = db;
const main = async () => {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
const usr = await User.create({ name: 'Igoro', email: '[email protected]' });
// console.log(usr.dataValues);
// const allUsers = await User.findAll({
// where: { name: 'George Bla' },
// raw: true,
// });
// // console.log(allUsers);
// let d1 = new Date(2021, 06, 22);
// let d2 = new Date(2021, 06, 21);
// console.log(d1);
// let a = await User.findAll({
// attributes: ['name', 'email'],
// where: {
// createdAt: {
// [Op.between]: [d2, d1],
// },
// },
// raw: true,
// });
// console.log(a);
// let a = await User.findOne({ where: { name: 'George Bla' }, raw: true });
// let b = await User.findAll({ where: { name: 'George Bla' }, raw: true });
// a.email = '[email protected]';
// await a.save();
// console.log(a);
// console.log(b);
};
// main();