Files
klz-cables.com/.pnpm-store/v10/files/29/0c8f7c29b26177da5cfd2d69a4db91b29519f386be7ba49766aeb229b146be5dce84406e9573bc274517c5b4a8fb4519e75b61695ac76abbc98484c677125a
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

33 lines
1.1 KiB
Plaintext

import toSnakeCase from 'to-snake-case';
import { upsertRow } from './upsertRow/index.js';
import { getTransaction } from './utilities/getTransaction.js';
export async function updateGlobal({ slug, data, req, returning, select }) {
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
const db = await getTransaction(this, req);
const existingGlobal = await db.query[tableName].findFirst({});
const result = await upsertRow({
...existingGlobal ? {
id: existingGlobal.id,
operation: 'update'
} : {
operation: 'create'
},
adapter: this,
data,
db,
fields: globalConfig.flattenedFields,
globalSlug: slug,
ignoreResult: returning === false,
req,
select,
tableName
});
if (returning === false) {
return null;
}
result.globalType = slug;
return result;
}
//# sourceMappingURL=updateGlobal.js.map