MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / upsert

Function upsert

packages/core/fumadb/src/query/orm/index.ts:427–447  ·  view source on GitHub ↗
(name, { where, ...options })

Source from the content-addressed store, hash-verified

425 return await internal.count(table, { where: constrainedWhere });
426 },
427 async upsert(name, { where, ...options }) {
428 const table = toTable(name);
429 const conditions = where ? buildCondition(table.columns, where) : undefined;
430 if (conditions === false) return;
431 let compiledWhere: Condition | undefined | false = conditions === true ? undefined : conditions;
432
433 compiledWhere = await applyUpdatePolicies(
434 table,
435 compiledWhere,
436 options.update,
437 context,
438 "upsert",
439 options.create,
440 );
441 if (compiledWhere === false) return;
442 await runCreatePolicies(table, options.create, context);
443 await internal.upsert(table, {
444 where: compiledWhere,
445 ...options,
446 });
447 },
448 async upsertMany(name, { target, update, values }) {
449 const table = toTable(name);
450 if (values.length === 0) return;

Callers

nothing calls this directly

Calls 4

buildConditionFunction · 0.90
toTableFunction · 0.85
applyUpdatePoliciesFunction · 0.85
runCreatePoliciesFunction · 0.85

Tested by

no test coverage detected