@payloadcms/plugin-multi-tenant
Version:
Multi Tenant plugin for Payload
19 lines (18 loc) • 668 B
JavaScript
import { getCollectionIDType } from '../utilities/getCollectionIDType.js';
import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js';
export const filterDocumentsBySelectedTenant = ({ req, tenantFieldName, tenantsCollectionSlug })=>{
const idType = getCollectionIDType({
collectionSlug: tenantsCollectionSlug,
payload: req.payload
});
const selectedTenant = getTenantFromCookie(req.headers, idType);
if (selectedTenant) {
return {
[tenantFieldName]: {
equals: selectedTenant
}
};
}
return {};
};
//# sourceMappingURL=filterDocumentsBySelectedTenant.js.map