32913/backend/src/db/api/tenantScope.js
2025-07-20 07:30:27 +00:00

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 };