Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing "JSONCollections is not defined" #1

Closed
boaticus opened this issue May 9, 2015 · 6 comments
Closed

Seeing "JSONCollections is not defined" #1

boaticus opened this issue May 9, 2015 · 6 comments

Comments

@boaticus
Copy link

boaticus commented May 9, 2015

I added the package to my meteor install, created a file in my /server dir with the name "mmj.mmjParticipants.collection.json"

When I try to read from the collection, I see:

(from a file I have called /lib/collections.js)
Participants = JSONCollections.mmjParticipants;
if (Participants.find().count() === 0) {
console.log("No participants.");
};

I'm getting "JSONCollections is not defined"

Any ideas what I may have done to get this?

@ephemer
Copy link
Owner

ephemer commented May 11, 2015

Hi, are you getting this error on the client or the server? At what point do you see it?

I think the problem may be with Meteor's load order rules (everything in the 'lib' directory will be loaded before other code). Try putting your code in a Meteor.startup() block:

Meteor.startup(function(){
 // your code
});

@boaticus
Copy link
Author

I was referencing it in a file in my /lib folder. I'll try wrapping it in a startup method as you suggested.

@boaticus
Copy link
Author

Yep, still same error, even when wrapped in a Meteor.startup.

image

image

The test json file lives at /private/tester.collection.json

@ephemer
Copy link
Owner

ephemer commented May 11, 2015

Hi Ken,

the file has to be named like this, otherwise it won’t be recognised and JSONCollections won’t exist:

something.collection_name.collection.json

On Mon, May 11, 2015 at 5:12 PM, Ken Wallace notifications@github.com
wrote:

Yep, still same error, even when wrapped in a Meteor.startup.
image
image

The test json file lives at /private/tester.collection.json

Reply to this email directly or view it on GitHub:
#1 (comment)

@boaticus
Copy link
Author

That was it. Thanks!

@ephemer
Copy link
Owner

ephemer commented May 11, 2015

My pleasure, glad you got it working!

@ephemer ephemer closed this as completed May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants