Dir structure (specifically schemas, collections, helpers)

I’ve read about structuring dirs:
best practices

But they are a bit too heavy for what I need right now.
My dir structure looks a bit like this
/lib/schemas/schemas.js - contains smart schemas
/lib/collection.js - contains db and collection declaration and collection helpers afterwards

I want these functions to be shared so hence the lib dir. But it’s a bit awkward to specify load order. My options, in order of preference are:

  1. Name files based on alphabetical sort order (_helper.js anyone?)
  2. Nest folder levels (/lib/helper, /lib/helper/collection, /lib/helper/collection/schemas)
  3. Have a large monolithic file that does it all

Is there a better method without looking into packages?

Bonus question: Why doesn’t this work?

Books = Books || new Mongo.Collection('books')

seems like your overcomplicating things.

what’s your end goal? Why do you need to specify load order?
Why do you need Books || new Mongo…?

I usually have a collection file with all the connected stuff in there. Example:

OrdersCollection = new Mongo.Collection('orders');

	insert: function (userId, doc) {
		// ...
	update: function (userId, doc, fields, modifier) {

	if (Meteor.isServer) {
		Meteor.publish('orders', function(){
			return OrdersCollection.find()

	OrdersCollection.attachSchema(new SimpleSchema({

Where do you keep your schemas in relation to this file?
And your collection helpers and collection hooks?

I’m going to end up with 10+ collections, so this file will get big.

My goal is to have place(s) where I can quickly see the schema, hooks, helpers, allow/deny etc of a certain collection without having to scroll too much. Actually this is what you mean isn’t it, ordersCollection.js? Hum, is good, thanks! :smile: