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

Function upsert

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

Source from the content-addressed store, hash-verified

347 return await internal.count(table, { where: constrainedWhere });
348 },
349 async upsert(name, { where, ...options }) {
350 const table = toTable(name);
351 const conditions = where ? buildCondition(table.columns, where) : undefined;
352 if (conditions === false) return;
353 let compiledWhere: Condition | undefined | false = conditions === true ? undefined : conditions;
354
355 compiledWhere = await applyUpdatePolicies(
356 table,
357 compiledWhere,
358 options.update,
359 context,
360 "upsert",
361 options.create,
362 );
363 if (compiledWhere === false) return;
364 await runCreatePolicies(table, options.create, context);
365 await internal.upsert(table, {
366 where: compiledWhere,
367 ...options,
368 });
369 },
370 async create(name, values) {
371 const table = toTable(name);
372 await runCreatePolicies(table, values, context);

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