Files
klz-cables.com/.pnpm-store/v10/files/3e/971bb9f2a05d72008c5343c09242de4dcdb977a113680afa6c5dfff239a37340ac3c14714c922bcf2535fb4367e46fa7bfbd0f497be60da7745c70006e2b45
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

45 lines
1.6 KiB
Plaintext

import { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js';
import { mergeListSearchAndWhere } from '../../utilities/mergeListSearchAndWhere.js';
export async function buildFolderWhereConstraints({ collectionConfig, folderID, localeCode, req, search = '', sort }) {
const constraints = [
mergeListSearchAndWhere({
collectionConfig,
search
})
];
const baseFilterConstraint = await (collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter)?.({
limit: 0,
locale: localeCode,
page: 1,
req,
sort: sort || (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : 'id')
});
if (baseFilterConstraint) {
constraints.push(baseFilterConstraint);
}
if (folderID) {
// build folder join where constraints
constraints.push({
relationTo: {
equals: collectionConfig.slug
}
});
// join queries need to omit trashed documents
if (collectionConfig.trash) {
constraints.push({
deletedAt: {
exists: false
}
});
}
}
const filteredConstraints = constraints.filter(Boolean);
if (filteredConstraints.length > 1) {
return combineWhereConstraints(filteredConstraints);
} else if (filteredConstraints.length === 1) {
return filteredConstraints[0];
}
return undefined;
}
//# sourceMappingURL=buildFolderWhereConstraints.js.map