Is there a way to exclude certain properties from client updates?
It should not be possible to see the property when inspecting a collection in the console
Absolutely.
Remove the autopublish
package which is turned on by default: meteor remove autopublish
Create your collection: Rooms = new Meteor.Collection("rooms");
No conditional isServer or isClient needed, as this should be present to both
In your server side code, publish only a subset of your collection by zeroing out the fields you don't want the client to have:
if (Meteor.isServer) {
//you could also Rooms.find({ subsetId: 'some_id' }) a subset of Rooms
Meteor.publish("rooms", function () {
return Rooms.find({}, {fields: {secretInfo: 0}});
});
}
NOTE: setting {secretInfo: 0}
above does not set all instances of secretInfo
for every row in the Rooms
collection to zero. It removes the field altogether from the clientside collection. Think of 0
as the off switch :)
Subscribe client side to the published collection:
if (Meteor.isClient) {
Deps.autorun(function() {
Meteor.subscribe("rooms");
});
}
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With