9 lines
308 B
JavaScript
9 lines
308 B
JavaScript
// Helper to apply tenant (company) scoping in findAll methods
|
|
function applyTenantScope(where, globalAccess, options) {
|
|
const userCompany = options?.currentUser?.companies?.id || null;
|
|
if (!globalAccess && userCompany) {
|
|
where.companiesId = userCompany;
|
|
}
|
|
}
|
|
|
|
module.exports = { applyTenantScope }; |