Skip to content

Commit d2fd207

Browse files
committed
[dev] dependencies updated to the latest ones
1 parent ae558a6 commit d2fd207

File tree

5 files changed

+557
-734
lines changed

5 files changed

+557
-734
lines changed

controllers/form.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ var db = require('../db');
33

44
module.exports = {
55
getData: function(req, res){
6-
db.User.findById(req.params.recordId).then(data => res.json(data));
6+
db.User.findByPk(req.params.recordId).then(data => res.json(data));
77
},
88
saveData: function(req, res){
9-
db.User.findById(req.body.id)
9+
db.User.findByPk(req.body.id)
1010
.then((user) =>
1111
user.update({
1212
name: req.body.name,

controllers/grid-dynamic.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
var db = require("../db");
1+
const db = require("../db");
2+
const Op = require('sequelize').Op
23

34
module.exports = {
45
getData : function(req, res){
56
var limit = (req.query.count || 20)*1;
67
var offset = (req.query.start || 0)*1;
78

8-
var where = req.query.filter ? { name:{ $like:"%"+req.query.filter.name+"%" }}: {};
9+
var where = (req.query.filter && req.query.filter.name) ? { name:{ [Op.like]:"%"+req.query.filter.name+"%" }}: {};
910
var order = req.query.sort ? [["name", req.query.sort.name ]] : [];
1011

11-
var count = db.Document.findAndCountAll({ where });
12-
var page = db.Document.findAll({
13-
where, limit, offset, order
14-
});
15-
16-
Promise.all([count, page]).then(data => res.json({
17-
pos:offset, total_count:data[0], data:data[1]
12+
var page = db.Document.findAndCountAll({ where, limit, offset, order });
13+
14+
page.then(data => res.json({
15+
pos:offset, total_count:data.count, data:data.rows
1816
}));
1917
}
2018
};

controllers/grid.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,39 @@ module.exports = {
77

88

99
removeData: function(req, res){
10-
db.User.findById(req.params.userId)
10+
db.User.findByPk(req.params.userId)
1111
.then((user) =>
1212
user.destroy())
1313
.then(() =>
1414
res.json({}));
1515
},
1616

1717
addData: function(req, res){
18+
const data = req.body;
19+
// force null values
20+
if (!data.birthday)
21+
data.birthday = null;
22+
if (!data.group_id)
23+
data.group_id = null;
24+
if (!data.age)
25+
data.age = 0;
26+
1827
db.User.create(req.body).then((obj) =>
1928
res.json({ id: obj.id }));
2029
},
2130
updateData: function(req, res){
22-
var { username, email, name, birthday, age, group_id } = req.body;
23-
console.log(username, birthday)
24-
db.User.findById(req.params.userId)
31+
const data = req.body;
32+
// force null values
33+
if (!data.birthday)
34+
data.birthday = null;
35+
if (!data.group_id)
36+
data.group_id = null;
37+
if (!data.age)
38+
data.age = 0;
39+
40+
db.User.findByPk(req.params.userId)
2541
.then((user) =>
26-
user.update(req.body))
42+
user.update(data))
2743
.then(() =>
2844
res.json({}));
2945
}

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
},
2323
"homepage": "https://github.com/webix-hub/webix-nodejs-demo",
2424
"dependencies": {
25-
"body-parser": "^1.17.2",
26-
"express": "~3.5.1",
27-
"express-handlebars": "^3.0.0",
28-
"formidable": "^1.1.1",
29-
"mongoskin": "~1.3.20",
30-
"mysql2": "^1.3.5",
31-
"sequelize": "^4.1.0"
25+
"body-parser": "^1.19.0",
26+
"express": "^4.17.1",
27+
"express-handlebars": "^3.1.0",
28+
"formidable": "^1.2.1",
29+
"mongoskin": "^2.1.0",
30+
"mysql2": "^1.7.0",
31+
"sequelize": "^5.21.1"
3232
}
3333
}

0 commit comments

Comments
 (0)