meteor-starter icon indicating copy to clipboard operation
meteor-starter copied to clipboard

Collections not available to client code when defined in /lib/collections

Open brylie opened this issue 10 years ago • 2 comments

We are following the pattern of defining our collections in /collections. However, on some client code, we get errors such as CollectionName is not defined. Where should collections be defined to ensure they are always available in client/server code?

brylie avatar Jul 02 '15 06:07 brylie

Two times when we are getting the CollectionName is not defined:

  • When calling the CollectionName from within /lib or /both
  • When calling the CollectionName from within /collections/hooks/

brylie avatar Jul 02 '15 07:07 brylie

If you can wrap your code in Meteor.startup when you want to access collection object. Other pattern you may use is to define collections in a local package (or each collection in separate packages) and add it to your project.

mpowaga avatar Jul 12 '15 16:07 mpowaga