Files
klz-cables.com/.pnpm-store/v10/files/0e/78d90c896497051d37836cadac2d3dcd4b8d1ac617dadb91614f6ee65593d1bb8eeeb8a6dce32f91584ebb500e2f57500e3fb2f8283839a1ffd76e80f1a083
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

28 lines
1.2 KiB
Plaintext

import { relations } from 'drizzle-orm';
export const buildDrizzleRelations = ({ adapter })=>{
for(const tableName in adapter.rawRelations){
const rawRelations = adapter.rawRelations[tableName];
adapter.relations[`relations_${tableName}`] = relations(adapter.tables[tableName], ({ many, one })=>{
const result = {};
for(const key in rawRelations){
const relation = rawRelations[key];
if (relation.type === 'one') {
result[key] = one(adapter.tables[relation.to], {
fields: relation.fields.map((field)=>adapter.tables[field.table][field.name]),
references: relation.references.map((reference)=>adapter.tables[relation.to][reference]),
relationName: relation.relationName
});
} else {
if (adapter.tables[relation.to]) {
result[key] = many(adapter.tables[relation.to], {
relationName: relation.relationName
});
}
}
}
return result;
});
}
};
//# sourceMappingURL=buildDrizzleRelations.js.map