JSPM

sequelize-multi-tenant-enhancer

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q49566F
  • License ISC

Multitenancy enhancer for Sequelize

Package Exports

  • sequelize-multi-tenant-enhancer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sequelize-multi-tenant-enhancer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Sequelize Multi Tenant Enhancer

A Proxy based enhancer function which enables schema based multi tenancy in Sequelize.

Installation

yarn add sequelize-multi-tenant-enhancer

Caveats

  • Requires Proxy support
  • Only tested for Sequelize V3

Example code

(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 ) => {
    ...
  } );