Open
Description
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