I have created a very simple example to try get my head round publish and subscribe.
I removed:
autopublish insecure
My mongo database looks like this
meteor:PRIMARY> db.country.find() { "_id" : ObjectId("5332b2eca5af677cc2b1290d"), "country" : "new zealand", "city" : "auckland" }
My test.js file looks like this
var Country = new Meteor.Collection("country");
if(Meteor.isClient) {
Meteor.subscribe("country");
Template.test.country = function () {
return Country.find();
};
}
if(Meteor.isServer) {
Meteor.publish("country", function() {
return Country.find();
});
}
my html file looks like this
<head>
<title>test</title>
</head>
<body>
{{> test}}
</body>
<template name="test">
<p>{{country}}</p>
</template>
I don't understand why this wouldn't work. I publish on the server, subscribe to it. I know this wouldn't be something I would do on a live environment but I can't even replicate retrieving the entire collection to view on the client.
If I change this return Country.find(); to return Country.find().count(); I get 1. The country text however does not appear.
Would love to know what is happening. I am new to development and using Meteor. I really like the framework.
Cheers
Country.findOne()? I think it may just be that the browser is unable to display the array of objects you returned byTemplate.test.countryhelper. - user728291