Skip to main content

The Document Model

A document is a supporting artifact attached to a war crime report — something like a statement, an official file, or a source citation. Unlike the file model (which tracks the raw uploaded bytes), a document carries metadata about a piece of evidence and links to the files that back it. Source: back/models/document.ts.

export const document_pure = {
title: string(),
description: optional(string()),
document_date: optional(coerce(date(), string(), (v) => new Date(v))),
document_number: optional(string()),
...createUpdateAt,
};

Pure fields

FieldTypeNotes
titlestring()evidence title
descriptionoptional(string())context
document_dateoptional(date)when the evidence dates from
document_numberoptional(string())e.g. a case reference number
createdAt / updatedAtspread from createUpdateAt

Relations

export const document_relations = {
documentFiles: {
schemaName: "file",
type: "multiple" as RelationDataType,
excludes: file_excludes,
relatedRelations: {},
},
report: {
schemaName: "report",
type: "single" as RelationDataType,
optional: false,
excludes: report_excludes,
relatedRelations: { documents: { type: "multiple" as RelationDataType, limit: 20 } },
},
};

Two things to note:

  • documentFiles is one-directional (relatedRelations: {}) — a file does not carry a documents back-list. Files are shared, flat resources; only the owning relation (uploader) keeps a back-list.
  • report is a required single relation with the reverse documents array — this is the "documents belong to a report" half of the graph shown on the Report model page.

Acts

get, gets, update, updateRelations, remove, add, count — plus the report flow acts (getRelated, getRelatedPagination) that hydrate document lists for a report.

Next: Content Models.