Created
January 10, 2016 04:45
-
-
Save sumn2u/9f26358112e707e1ac46 to your computer and use it in GitHub Desktop.
list file inside routes file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = require('../database.js'); | |
//creates a new entry | |
exports.getList = function(req, res){ | |
db.ListEntry.find(function(err, entries){ | |
if(err){ | |
console.log(err); | |
} | |
// console.log(entries); | |
// var content = {content: entries}; | |
// res.send(content, 302); | |
res.send(entries, 302); | |
}); | |
// res.send(index.html); | |
// var newEntry = new db.ListEntry({ | |
// task:"Freger loas platos", | |
// status:0 | |
// }); | |
// newEntry.save(function(err){ | |
// if(err){ | |
// console.log(err); | |
// } | |
// }); | |
// console.log("We have created a new entry"); | |
// res.send("getting the lists"); | |
}; | |
exports.createEntry = function(req,res){ | |
var newEntry = db.ListEntry({ | |
task:req.body.task, | |
status:0 | |
}); | |
newEntry.save(function(err){ | |
if(err){ | |
console.log(err); | |
}else{ | |
console.log("successfully saved"); | |
res.send(201); | |
} | |
}); | |
}; | |
exports.createList= function(req,res){ | |
db.ListEntry.update({status:1}, function(err){ | |
if(err){ | |
console.log("Update failed"); | |
res.send(500); | |
} | |
res.send(200); | |
}); | |
}; | |
exports.deleteEntry = function(req,res){ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment