Skip to content

Instantly share code, notes, and snippets.

@claustres
Last active September 5, 2017 05:00
Show Gist options
  • Save claustres/2de6d62ad42b6f69b1b7f16ac67e76bb to your computer and use it in GitHub Desktop.
Save claustres/2de6d62ad42b6f69b1b7f16ac67e76bb to your computer and use it in GitHub Desktop.
Organisation service on a segregated DB
import service from 'feathers-mongodb'
function createOrganisationService (hook) {
let organisationDb = app.db.db(hook.result._id.toString())
app.use(hook.result._id.toString() + '/assets', service({
Model: organisationDb.collection('assets')
})
return hook
}
...
app.service.('organisations').hooks({
after: {
create: createOrganisationService
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment