-
Notifications
You must be signed in to change notification settings - Fork 2
/
dbConnector.js
47 lines (33 loc) · 857 Bytes
/
dbConnector.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
42
43
44
45
var dbTool = require('../models/dbTools');
var updateData = function(req,res,action){
var dataID = {id:req.params.id};
dbTools.updateData(dataID,action,function(sucess,res){
if(success) res.json({status:'OK'});
else res.json({status:'Error'});
});
}//end updateData
module.exports = function(app){
app.get('/', function(req,res){
res.render('index',{movies:result});
});
app.post('/Mpath',function(req,res){
var data = {
title:req.body.title,
likes:0,
unlikes:0
};
dbTools.saveAirData(movie,function(success,result)
{
if(sucess) res.json({status:'OK'});
else res.json ({status:'Error'});
});
});
app.put('/data/folder/:id',function(req,res){
updateData(req,res,'field');
});
app.put('/data/folder1/:id',function(req,res){
updateData(req,res,'field');
});
//put all data to application here
//
};