Posts=newMeteor.Collection('posts');Meteor.methods({post:function(postAttributes){varuser=Meteor.user(),postWithSameLink=Posts.findOne({url:postAttributes.url});// ensure the user is logged inif(!user)thrownewMeteor.Error(401,"You need to login to post new stories");// ensure the post has a titleif(!postAttributes.title)thrownewMeteor.Error(422,'Please fill in a headline');// check that there are no previous posts with the same linkif(postAttributes.url&&postWithSameLink){thrownewMeteor.Error(302,'This link has already been posted',postWithSameLink._id);}// pick out the whitelisted keysvarpost=_.extend(_.pick(postAttributes,'url','title','message'),{userId:user._id,author:user.username,submitted:newDate().getTime()});varpostId=Posts.insert(post);returnpostId;}});