Miles
Miles

Reputation: 1635

Subscribing to a collection error

I'm really not sure what the issue is here. Maybe I don't understand the publish/subscribe docs enough.

In my server directory:

Meteor.publish("kudos", function () {
  return Kudos.find({});
});

In my client directory:

Meteor.startup(function(){
  Meteor.subscribe("kudos");
});

Template.launchsection.kudos = function () {
  return Kudos.find({});
};

When I run this, I get an error of Kudos is not defined for the line that returns Kudos.find({});.

What am I missing?

Upvotes: 1

Views: 210

Answers (2)

Derander
Derander

Reputation: 91

Specifically, you need to write Kudos = new Meteor.Collection("kudos") in both your client and server directory.

Upvotes: 4

jsbeckr
jsbeckr

Reputation: 1193

Make sure that you define the Schema in a js file which is executed on both, client and server. A file Schema.js in the root folder of your meteor app should do the trick. Have a look at this question.

Hope that helps! :)

Upvotes: 3

Related Questions