meteor-starter
meteor-starter copied to clipboard
Collections not available to client code when defined in /lib/collections
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?
Two times when we are getting the CollectionName is not defined:
- When calling the
CollectionNamefrom within/libor/both - When calling the
CollectionNamefrom within/collections/hooks/
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.