I this possible to publish multiple collections in single subscription call? if so please guide me.
Yes. A publish function can return an array of cursors. For example:
client
Meteor.subscribe('roomAndMessages');
server
Meteor.publish("roomAndMessages", function (roomId) {
check(roomId, String);
return [
Rooms.find({_id: roomId}),
Messages.find({roomId: roomId})
];
});
important note
If you return multiple cursors in an array, they currently must all be from different collections. We hope to lift this restriction in a future release.
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