Tearleads

document_container_projection Client SQLite table

Local many-to-many projection between documents and containers.

Declared in packages/client-sdk/src/data/sqlite/schema/documentProjectionSchema.ts

Description

The document summary row stores one selected containerId for primary list placement, while this table keeps the full set of linked containers returned by container/document sync. Removing a container deletes its links and may repair affected document summary rows to point at another remaining link.

Indexes:

  • (documentId, containerId) is the primary key and prevents duplicate links for the same document/container pair.
  • (containerId, documentId) serves the container-filtered link scans (folder item and sidebar windows) as a covering index search.

Columns

  • document_idtext
    • not null

    Server document id whose container links are projected.

  • container_idtext
    • not null

    Linked container id.

  • updated_attext
    • not null

    Local timestamp for the last replacement of the link set.

Keys and constraints

  • Primary key(document_id, container_id)

Indexes

  • document_container_projection_container_idx(container_id, document_id)

    DDL

    The statements the client runs to create this table and its indexes.

    CREATE TABLE IF NOT EXISTS "document_container_projection" (
      "document_id" TEXT NOT NULL,
      "container_id" TEXT NOT NULL,
      "updated_at" TEXT NOT NULL,
      PRIMARY KEY ("document_id", "container_id")
    );
    
    CREATE INDEX IF NOT EXISTS "document_container_projection_container_idx" ON "document_container_projection" ("container_id", "document_id");