-
Notifications
You must be signed in to change notification settings - Fork 7
/
admin.js
36 lines (29 loc) · 940 Bytes
/
admin.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
/**
* Created with JetBrains WebStorm.
* User: hariharasudhan
* Date: 27/11/13
* Time: 8:33 AM
* To change this template use File | Settings | File Templates.
*/
var Admin = exports = module.exports = {};
var db = require("./connect");
var SeedDetail = require("./seed_detail");
var User = require("./users");
Admin.initialize = function(app){
app.get('/admin/users',function(request,response){
User.page(1,function(data){
response.render("users",{data:data})
})
});
app.post('/admin/user/edit',function(request,response){
var sql = "UPDATE users SET "+request.body.name+ " = ? WHERE ID = ?";
db.query(sql,[request.body.value,request.body.pk],function(err,rows){
if(!err){
response.json({success:true});
}else{
console.log(err);
response.json(400,"Cannot Update");
}
})
});
}