Sorry if this has already been asked before.
How do you get documents that are outside of your initial publications?
For example, let’s say I have posts with the following fields:
{
_id: String
password: String (optional),
body: String,
createdAt: Date
}
The posts with a password only have some metadata published and the posts without a password is completely published:
Meteor.publish('locked_posts', function() {
return Posts.find({ password: { $exists: true } }, { fields: { createdAt: 1 } });
});
Meteor.publish('public_posts', function() {
return Posts.find({ password: { $exists: false } });
});
The view looks like this:
{{ #each posts }}
{{ #if password }}
<input type="password">
{{ else }}
<div>{{ body }}</div>
{{ /if }}
{{ /each }}
Inside a template, a user should be able to enter a post’s password and get that post’s body:
So do I re-publish that single post, for which the password was entered, with all the fields, and refresh the template to display this new post?