Skip to main content
DocumentExtraction stores the parsed-text output of one parser run against one Document. Each row represents a single (document, parser_name, parser_version) execution result and acts as a caching layer: the extraction orchestrator checks for an existing active row whose parser_name + parser_version + source_checksum match the current request and reuses the stored text instead of calling the remote parser (LlamaParse, LiteParse) again. One document may accumulate multiple rows when different parsers or parser versions are used; only one row per (document_pk, parser_name, parser_version, COALESCE(source_checksum,”)) is active at any time, enforced by a partial unique index on deleted_at IS NULL. The entity is workspace-scoped for tenant isolation and cleanup queries.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • document_extraction_id — generated by gen_random_uuid() database default at INSERT; never supplied by the caller
  • created_at — set once via MikroORM onCreate hook (new Date()); immutable after creation
  • updated_at — set by MikroORM onUpdate hook (new Date()) on every subsequent flush; null until the first update
  • deleted_at — written by the extraction orchestrator or backfill services to soft-delete superseded rows; the partial unique index is scoped to deleted_at IS NULL so a new parser run can replace a deleted cache entry without a constraint violation
  • Cache-dedup logic — DocumentExtractionRepository (or the orchestrator) queries for an existing active row matching (document_pk, parser_name, parser_version, source_checksum) before calling the remote parser; a hit returns the stored text without an external API call
  • source_checksum coalesce sentinel — the partial unique index uses COALESCE(source_checksum, ”) so a null checksum does not cause PostgreSQL to treat every null-checksum row as distinct (PostgreSQL treats NULLs as distinct in unique indexes by default)
  • Workspace scope — workspace_pk is always set to req.workspace.pk at write time by the extraction pipeline; never accepted from client input
  • parser_name and parser_version are stamped at extraction time from the calling service constant and the deployed parser SDK version; not user-supplied

Example

Source: /Users/maximechampoux/platform/apps/api/src/database/entities/DocumentExtraction.ts · domain: ingestion · tier: Infrastructure