Skip to content

add multi tenant support #3

Open
@mailaneel

Description

@mailaneel

Allow support of multi tenants

In settings

{
  // this could be specific to the adapters
  tenantStrategy: {
    // if these keys are not preset we throw validation error
    // and based on tenant strategy we might have to add these to every query we make to db
    tenantKeys: ['accountId'], // or (config, params) => ['accountId']

    // for mongo adapter return new db
    getDB: (config, params) => config.client.db(`${config.collection}-${params.accountId}`),

    // for mongo adapter return new collection
    getCollection: (config, params) => config.db.collection(`${config.collection}-${params.accountId}`),

    // for mongoose
    getModel: (config, params) => config.model,

    // if exists will override the adapter find or update the params and call adapter's find
    find: () => null
    // ... other methods
  }
}

And tenant strategies can be implemented by the adapters itself, example incase of mongoose, whether to use that as shardKey or use a separate collection or use a separate db

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions