You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are fine!. With findOne instead find I get the follow error:
But. Why is not possible I use findOne?, I want to find a single document, should be possible use it appropriately named findOne.
I self answer the question: Publications need return a cursor (find), not a object (findOne).
According with meteor documentation (http://docs.meteor.com/#/full/findone)
findOne is Equivalent to find(selector, options).fetch()[0] with options.limit = 1.
So I change the code in publications/posts.js to:
Meteor.publish('posts.single',function(postId){check(postId,String);constselector={_id: postId};// here the changeconstoptions={limit: 1};returnPosts.find(selector,options);//});
It works! and I think that it is more efficient :)
I think is better use findOne instead find to fetch the post
https://github.com/mantrajs/mantra-sample-blog-app/blob/master/server/publications/posts.js
The text was updated successfully, but these errors were encountered: