Confused about collection management in 1.3 - where do you define it?

I’m not exactly sure anymore where we’re supposed to define our collections in 1.3.
Previously I would define the collections in a lib folder, now I’m not so sure anymore due to load order.

Currently I have mine defined in the server folder but I think that is causing errors since its not available on the client. Would I define my collection in the root import folder as well?

With meteor 1.3 you can use import.
Define your collection inside /imports/api/. Ex: /imports/api/products/products.js

And then if you need to access the collection from server code or client code, you can just import it.

Read this:

Read also about eager loading and lazy loading. Prefer to use lazy loading.

1 Like