lundi 2 mars 2015

Node.js MongoDB Update doesn't work


I'm new in MongoDB and i am trying to use it in Node.js.


I'm having a problem in doing an update of a specific document. I don't get any error but it don't update the data in the collection.


Can anyone tell me what i'm i doing wrong?



app.post("/update", function(req,res)
{
var query = req.query;
var code = query.code;

var db = req.db;
var data = db.get("data");

data.update(
{
code : code
},
{
course : req.body.course,
grade : req.body.grade,
year : req.body.year,
code : req.body.code
},
function (err, result) {
if (err) console.log("erro:" + err);
console.log("result" + result);
}
);
});


Thanks





Aucun commentaire:

Enregistrer un commentaire