(facts: Array<Omit<CatalogFact, 'fact_id' | 'created_at' | 'superseded_by'>>)
| 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 |
no test coverage detected