(author.id)
我的路线:
router.get('/articles/authors/:id', function(req, res){
Article.find( {author.id: req.params.id} ).sort( {createdAt: -1} ).exec(function(err, articles){
if(err){
console.log(err);
return req.flash('error', 'Unable to find author.');
} else {
console.log(articles);
res.render('authors/', {
articles: articles,
pagetitle: 'Articles by '
});
}
});
});
author:
{
id:
{
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String,
name: String
},
如果有人能看到我的错误,我将不胜感激。