Reputation: 141
I'm trying to create an web app where a student can store their notes online. So, if they login they can only see the notes that they posted on the blog.
view.on('init', function (next) {
Post.model.findOne()
.where('_id', User.id)
.populate('author')
.exec(function(err, results) {
locals.data.posts = results;
});
});
this is the code that I am having problems on
Upvotes: 1
Views: 349
Reputation: 141
view.on('init', function (next) {
var q = keystone.list('Post').paginate({
page: req.query.page || 1,
perPage: 10,
maxPages: 10,
})
.find().where('author', locals.user.id)
.sort('-publishedDate')
.populate('author categories');
if (locals.data.category) {
q.where('categories').in([locals.data.category]);
}
q.exec(function (err, results) {
locals.data.posts = results;
next(err);
});
});
This works!
Upvotes: 1