I am trying to find a specific object in my mongodb, currently I iterate through the entire id and match string by string in jade template engine, but surely there is a more efficient way of doing search object in mongo
app.put('/tasks/:id', function(req, res){
Task.findById(req.params.id, function (err, doc){
doc.updated_at = new Date();
doc.task = req.body.task.task;
doc.save(function(err) {
if (!err){
res.redirect('/tasks');
}
else {
// error handling
}
});
});
});
Alternatively, I can
db.TASK.find(
{ Task: 'blah blah.....' },
)
in the command line
but I don't know how to have the server side respond to different task dynamically, that is 'blah blah' should be dynamic and I don't know how to incorporate that into node.js
Any hint would be appreciated