I have started learning MeteorJS and made a sample app. I have a collection in mongoDB and I am trying to see that collection in client Here is my server Code(file is in /libs)
newColl=new Meteor.Collection("newColl");
if(Meteor.isServer){
Meteor.publish('newCollectionData', function(){
console.log(newColl.find().fetch());
return newColl.find();
});
}
Here is My client Code(file is in /client)
Meteor.subscribe("newCollectionData");
//console.log(newColl.find());
console.log(newColl.find().fetch());
var data= newColl.find().fetch();
console.log(data);
The log in server prints the data correctly but the log on client prints an empty array. PS: I have removed auto publish, but with it also it was giving same result. Where am I going Wrong?
Meteor.subscribe("newCollectionData",function(){console.log(newColl.find().fetch());});