Files
klz-cables.com/.pnpm-store/v10/files/65/7485048fce8f5be47dd4f67fae98195d3ce4d06c806f979f6e3f483eb17bb289cd245fa2e3bd2b7ed9a8441200b9db8ecd51d6591307e869fee875effabde7
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.3 KiB
Plaintext

import { combineQueries } from '../../index.js';
/**
* Returns whether or not the entity doc exists based on the where query.
*/ export async function entityDocExists({ id, slug, entityType, locale, operation, req, where }) {
if (entityType === 'global') {
const global = await req.payload.db.findGlobal({
slug,
locale,
req,
select: {},
where
});
const hasGlobalDoc = Boolean(global && Object.keys(global).length > 0);
return hasGlobalDoc;
}
if (entityType === 'collection' && id) {
if (operation === 'readVersions') {
const count = await req.payload.db.countVersions({
collection: slug,
locale,
req,
where: combineQueries(where, {
parent: {
equals: id
}
})
});
return count.totalDocs > 0;
}
const count = await req.payload.db.count({
collection: slug,
locale,
req,
where: combineQueries(where, {
id: {
equals: id
}
})
});
return count.totalDocs > 0;
}
return false;
}
//# sourceMappingURL=entityDocExists.js.map