UNPKG

@payloadcms/plugin-multi-tenant

Version:
19 lines (18 loc) 668 B
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