Last active
September 5, 2017 05:00
-
-
Save claustres/2de6d62ad42b6f69b1b7f16ac67e76bb to your computer and use it in GitHub Desktop.
Organisation service on a segregated DB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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