I have the following code, i’m fairly certain it should work…
but it always only finds printinglist as an accessible collection.
it should actually be that i can access shops and allShops in chrome if i type those publication names in the console… I haven’t used meteor database functionality for a while but i don’t think anything changed here?
in collections.js in lib folder:
printinglist = new Mongo.Collection('printshops');
if (Meteor.isServer) {
Meteor.startup(function() {
});
Meteor.publish('shops', function (city) {
return printinglist.find({ cityid: city });
});
Meteor.publish('allShops', function() {
return printinglist.find();
});
I don’t get it: what would you want to see in the console?
Your code looks fine to me, except for the second subscribe that might better be inside an autorun.
If I’d type in shops or allShops in the console it should show me both these publications/subsets of the collection, right? But this does not happen. Both shops and allShops are undefined
Yea, my bad. Haven’t been using pub/sub for a while and I confused how it worked because of the reactivity I need. Could you give an example of how to do the reactivity for the publish function?
But I can’t get it to work to publish a new set based on data changes. I’ve tried it with tracker but I must be doing something wrong. I’m guesing it doesn’t recompute because there’s no reactive data source (the argument passed to the function is not reactive I’m guessing, so how to do it?)