MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / insertFacts

Method insertFacts

server/src/db/catalog-db.ts:465–489  ·  view source on GitHub ↗
(facts: Array<Omit<CatalogFact, 'fact_id' | 'created_at' | 'superseded_by'>>)

Source from the content-addressed store, hash-verified

463 }
464
465 async insertFacts(facts: Array<Omit<CatalogFact, 'fact_id' | 'created_at' | 'superseded_by'>>): Promise<string[]> {
466 if (facts.length === 0) return [];
467
468 const client = await getClient();
469 const ids: string[] = [];
470 try {
471 await client.query('BEGIN');
472 for (const fact of facts) {
473 const factId = uuidv7();
474 ids.push(factId);
475 await client.query(
476 `INSERT INTO catalog_facts (fact_id, fact_type, subject_type, subject_value, predicate, object_value, source, confidence, actor, provenance_type, provenance_context, expires_at)
477 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`,
478 [factId, fact.fact_type, fact.subject_type, fact.subject_value, fact.predicate, fact.object_value, fact.source, fact.confidence, fact.actor, fact.provenance_type, fact.provenance_context, fact.expires_at]
479 );
480 }
481 await client.query('COMMIT');
482 } catch (err) {
483 await client.query('ROLLBACK');
484 throw err;
485 } finally {
486 client.release();
487 }
488 return ids;
489 }
490
491 // ═══════════════════════════════════════════════════════════════════════════
492 // Identifier linking

Callers 1

resolveIdentifiersMethod · 0.95

Calls 3

uuidv7Function · 0.85
queryMethod · 0.80
getClientFunction · 0.70

Tested by

no test coverage detected