Remove unused dependency regexp-quote
Reorder package.json dependencies alphabetically

This is what happens when you do 'npm install module --save', so it
makes sense to do this in a separate commit so future commits don't have
so much noise in them.
Upgrade express to v3.17.5

This is the latest version in the 3.x series and contains deprecation
warnings that should be helpful when upgrading to the 4.x series.
Update dev dependencies
Remove assert dependency

Node already provides this module in core, so it's unnecessary to have
this as a dependency as it's just a mirror of what node provides.
Move glob module into devDependencies

The glob module is only used within the test suite, so there's no need
for it to be in the main dependencies section.
Use app.delete instead of app.del

This fixes a deprecation warning in the latest version of express.
upgrade npm on travis to avoid dependency detection issues

see https://github.com/npm/npm/issues/4984 for details. Without this the
ncp dependency of fs-extra fails to install.
Change findMemberships to be an instance method

Rather than having this as a private implementation we expose the method
on the instance so we can actively find memberships when we need then.

This also has the added bonus of making the method signature simpler.
When we get rid of the pre init hook we can also drop the id argument
and just use the instance's id.
Remove skipMemberships flag and manually retrieve memberships

This doesn't entirely work currently because the memberships themselves
don't have the findMemberships method. Perhaps the best thing to do
would be to stub that method on the memberships model or similar.
Fix memberships tests
Add populateMemberships method with consistent interface

The populateMemberships method handles populating the memberships on a
model by calling the findMemberships method. This method is also added
to the Membership model as a blank implementation so that all the models
behave in the same way and no conditionals are required in app.js.
Check the _id and id fields in findMemberships method

When documents are constructed from search results they only have an
'id' field. When they are newly created they only have the '_id' field,
so we check for both.
Populate memberships in search results
Handle blank embed parameter

If the embed parameter is provided but is empty then memberships should
be skipped completely.
Fix embedded memberships in joined documents

When using the ?embed parameter to specify joins the joined documents
weren't getting their memberships added.

This change uses 'getValue', which in turn calls the mpath module to get
an array of models based on the populated path. This can also be an
array of arrays if the document is nested more than one layer deep, so
we flatten the array before processing to normalize it.
Handle errors when populating joins
Check models are valid before populating memberships

Avoid errors with possibly null models by compacting the models array to
remove falsy values and filtering the array to ensure all members have
the required method.
WIP member needs to be handled on membership embeds

Also start adding some tests