Skip to content

Instantly share code, notes, and snippets.

@mhinton
Last active August 29, 2015 14:05
Show Gist options
  • Save mhinton/c0c40d90d9aded20e71c to your computer and use it in GitHub Desktop.
Save mhinton/c0c40d90d9aded20e71c to your computer and use it in GitHub Desktop.
Meteor Publish/Subscribe Issue
/* file: server/data.js */
Meteor.publish("helptexts",function() {
return HelpTexts.find();
});
Meteor.publish("publishTest", function () {
return HelpTexts.find({_id: "help-demo"});
});
/* file: client/base.js */
if (!window.HelpTexts) { HelpTexts = new Meteor.Collection("helptexts"); }
if (!window.PublishTest) { PublishTest = new Meteor.Collection("publishTest"); }
helptexts_subscription = Meteor.subscribe("helptexts");
publish_test_subscription = Meteor.subscribe("publishTest");
/* in Chrome javascript console */
HelpTexts.findOne({_id: "help-demo"}); // <- returns the document
PublishTest.findOne(); // <- returns undefined
PublishTest.find({_id: "help-demo"}).fetch(); // <- returns []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment