I've a collection named billers
. I published this collection on the server, as below:
Meteor.publish("billers",function(){
return billers.find();
});
In the client code, I subscribe to billers
, with a callback as below:
Session.set('data_loaded',false);
Meteor.subscribe("billers",{
onReady : function() {console.log("data loaded");
Session.set('data_loaded',true);}
});
Then, I have a helper in the client that returns documents from billers
when the data_loaded
session variable is true
:
Billers : function(utility){
if(Session.get('data_loaded')==true){
if(billers.find().count()==0)
console.log("zero");
else
console.log("not zero");
return billers.find({utility:utility});
}
},
I access this in the template using {{#each Billers}}
On localhost: Everything works fine. The console prints data_loaded
, followed by count not zero
, and all the fetched documents are displayed.
When deployed to subdomain.meteor.com: The console prints data_loaded
which means the database is ready to use. However, now it prints zero
, which indicates that the find().count()
returned 0. So 0 documents were fetched. So, none of the documents are shown in the template.
The collection does have documents, as verified by the correct working on localhost, and I also independently checked via a mongodb client. How do I fix this issue? This seems like a Meteor problem to me..