This file contains 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 mongoose, { Schema } from 'mongoose' | |
import { getCurrentTenantId } from './storage' | |
/** | |
Function will return another function, which will further return a mongoose discriminator. | |
The only difference here is that everytime you use the mongoose model, you will have to call a function, | |
but it will give you a freedom of passing tenant-based data. | |
*/ | |
export function tenantModel(name, schema, options) { | |
return (props = {}) => { |