A Proxy based enhancer function which enables schema based multi tenancy in Sequelize.
yarn add sequelize-multi-tenant-enhancer
- Requires Proxy support
- Only tested for Sequelize V3
(Assumes that schemas with tables are already in place)
const enhance = require( 'sequelize-multi-tenant' );
const seq = someFunctionWhichInitializesTheDbAndDefinesAllModels();
const enhancedSeq = enhance( seq );
const clientA = enhancedSeq.withSchema( 'client-a' );
clientA.models.Foobars.findAll()
.then( ( results ) => {
...
} );