mongodb - How to related/associate to Mongo Collections in Meteor without using simple schema -
i working on meteor project.
step 1
i've added accounts-password , accounts-ui packages in order have users collection , authenticating system.
step 2
i've created mongo collection 'posts' of documents following fields: _id, title, description , createdon(date).
step 3
i've created mongo collection 'comments' of documents following fields: _id, comment ,postedon('date') , createdby(meteor.user()._id)
step 4
i've added iron router package , set routing. can view blog list , go single post detail page. want give possibility users logged in post comments on single comment without using aldeed simple-schema package.
find below snippets project:
 template.posts_list.helpers({     posts:function(){         return posts.find({}, {sort: {createdon: -1} });     } })  template.comments.helpers({     comments:function(){         return comments.find({ ?????  ho can associate comments single post? });      } })   i wondering how can make proper association between 2 collections. show comments associated related post. of comments appear every post without distinction. help? thanks
you want add postid comments schema. then, whenever you're submitting comment, _id of post in question , send meteor method you're inserting comment. this:
// in template events: 'submitcommentform': function( event, template ) {     var postid = this._id; // make sure post data context of form set in #each or #with.     meteor.call('addcomment', event.target.comment, postid, ...) // assuming comment in sort of named input comment name. }      
Comments
Post a Comment