meteor - Publishing/subscribing multiple field selection of the same collection -
I have a post archive containing an embedded array of comments, in each post view page, I will have to publish 2 cursors: Some wigs in a witch include all posts without their post field (exhibit) to show in the widget, and the other witch contains the posts selected along with its comments. The server side code looks like this:
Meteor.publish ('all posts', function) {return Posts.find ({}, {fields: {'comments':}}}} ) Meteor.publish ('singlepost', function (slug) {return post.fund ({slug: slug}}} In the post view template, I subscribe to both of these , But when I use
Posts.findOne ({slug: slug}) How can I know that the use of the Witch Publishing Cursor Is done? When I query mail on the client, then I How can I choose?
You are asking the union of all active membership on that archive. If you have subscribed Singlepost to that particular slug , you will get the full document. If you do not have it, you will not get the comment. Another example:
Meteor.publish ("All Summary", function () {back post.find ({}, {field} : {Title: 1, date: 1}})}}; Meteor.publish ("myPosts", function () {return posts.find ({creator: this.userId}, {fields: {title: 1, rating: 1}})}} Meteor.publish ("singlepost" Function (_id) {return Posts.find ({_ id: _id}, {fields: {title: 1, body: 1});}); Suppose userId " Any customer with "me" has been subscribed with all sources , myPosts and singlePost for "3" and _id ) These documents are in the collection: {_ id: "1", title: "post 1", date: "tomorrow", producer: "No Rating: 4} {_id:" 3 ", Title:" Post 3 ", Title:" 2 ", Title:" Post 2 ", Titles Thum: "Today", Producer: "Me", Rating: 4} {_id: "3" for post 1, Client will only see Title and And date (and _id ) - published from all sources - nothing else. For post 2, they can be found in the title < / Code>, date , and ratings - date will come from all sources , title From all sources and myPosts , and ratings to myPosts code>. For post 3, they will see title , date and body , but will not see rating .
Comments
Post a Comment