Files
klz-cables.com/.pnpm-store/v10/files/66/fa95613d35356d0af4fb3fb14000ad39844ab9f0dfcfba977a5dcfa05914ddd36f3d5150aac9f438d0c13ebafd6d10cdd3188b3bd6da38d97092a4a809d132
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.5 KiB
Plaintext

import { and, eq, inArray } from 'drizzle-orm';
export const deleteExistingRowsByPath = async ({ adapter, db, localeColumnName = '_locale', parentColumnName = '_parentID', parentID, pathColumnName = '_path', rows, tableName })=>{
const localizedPathsToDelete = new Set();
const pathsToDelete = new Set();
const table = adapter.tables[tableName];
rows.forEach((row)=>{
const path = row[pathColumnName];
const localeData = row[localeColumnName];
if (typeof path === 'string') {
if (typeof localeData === 'string') {
localizedPathsToDelete.add(path);
} else {
pathsToDelete.add(path);
}
}
});
if (localizedPathsToDelete.size > 0) {
const whereConstraints = [
eq(table[parentColumnName], parentID)
];
if (pathColumnName) {
whereConstraints.push(inArray(table[pathColumnName], Array.from(localizedPathsToDelete)));
}
await adapter.deleteWhere({
db,
tableName,
where: and(...whereConstraints)
});
}
if (pathsToDelete.size > 0) {
const whereConstraints = [
eq(table[parentColumnName], parentID)
];
if (pathColumnName) {
whereConstraints.push(inArray(table[pathColumnName], Array.from(pathsToDelete)));
}
await adapter.deleteWhere({
db,
tableName,
where: and(...whereConstraints)
});
}
};
//# sourceMappingURL=deleteExistingRowsByPath.js.map