Skip to content

Instantly share code, notes, and snippets.

@xsyn

xsyn/gist:992780

Created May 26, 2011
Embed
What would you like to do?
Callback with res
== model/dreamModel.js
DreamModel.prototype.save = function(articles, callback) {
if( typeof(articles.length) == 'undefined') {
articles = [articles];
}
for(var i=0;i<articles.length;i++) {
article = articles[i];
articles.created = new Date();
}
this.db.save(articles, function(err, res) {
if(err) {
console.log(err)
callback(err)
} else {
callback(null, res);
}
});
};
== Node app.js
app.post('/dreams/dreams', function(req, res) {
var document = new DreamModel(req.body['dream']);
document.save(req.body['dream'], function(req, res) {
res.redirect('/dreams');
});
});
== Error
/Users/xsyn/Development/didit.co.za/pages.js:65
res.redirect('/dreams');
TypeError: Object [{"id":"f3ea24911c5bfcce15cfb25160005d31","rev":"1-7591d82bf8117e46ab1ac6320521ee89"}] has no method 'redirect'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.