Files
klz-cables.com/.pnpm-store/v10/files/d8/fb29249c60af6fe6723120f7b031ff226e42077a9dadfcf28aa0ad993186f605abd06c8db774933ead03d7a16f406898e028c4876386c371afecef5d74306d
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

21 lines
1.1 KiB
Plaintext

export const insert = async function({ db, onConflictDoUpdate, tableName, values }) {
const table = this.tables[tableName];
// Batch insert if limitedBoundParameters: true
if (this.limitedBoundParameters && Array.isArray(values)) {
const results = [];
const colsPerRow = Object.keys(values[0]).length;
const maxParams = 100;
const maxRowsPerBatch = Math.max(1, Math.floor(maxParams / colsPerRow));
for(let i = 0; i < values.length; i += maxRowsPerBatch){
const batch = values.slice(i, i + maxRowsPerBatch);
const batchResult = onConflictDoUpdate ? await db.insert(table).values(batch).onConflictDoUpdate(onConflictDoUpdate).returning() : await db.insert(table).values(batch).returning();
results.push(...batchResult);
}
return results;
}
const result = onConflictDoUpdate ? await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning() : await db.insert(table).values(values).returning();
// See https://github.com/payloadcms/payload/pull/11831#discussion_r2010431908
return result;
};
//# sourceMappingURL=insert.js.map