I'm trying to show posts by the current logged in user. I tried the same method which I used for showing comments under related post's page but doesn't work for logged in user's posts.
Template.myPosts.helpers({
posts: function () {
selector = {userId: this.userId};
options = {sort: {createdAt: -1}};
return Posts.find(selector, options);
}
});
I also tried the code below in router.js (iron router package installed):
this.route('myPosts', {
path:'/my-posts',
data:function(){
return Posts.find({userId: this.userId})
}
});
})
If the code above is not close to how it should be, any hints on how to proceed will be well appreciated. This is a project for only learning purposes.
Thanks!