Meteor.publish("desktopItems", function () {
var items = Items.find({ desktopOwner: this.userId });
console.log("publish desktopItems", this.userId, items.count());
return items;
});
It works perfectly, and I can add items directly in MongoDB then they appear in the browser.
BUT ! It doesn’t work just after I log in. When this is the case, I can see the log message appear in the meteor console, saying there is indeed a valid userId, and that items.count() is greater than zero, but in my helper, the find method returns an empty cursor. All I can do to get it to work is to reload the page…
Actually I think I may have fixed it. I think it was an issue with login. I changed to the new state before Meteor.userId() had a value. Now I wait until Meteor.userId() has a value, and it seems to be working.