Loading exercise…

Document revision workspace

Implement document changes without silently overwriting another editor’s work.

Task

Build a document editor that creates, updates, and deletes documents without silently overwriting a newer revision.

Requirements

  1. Return {documents, error}. Error is null or one of exists, missing, conflict, invalid.
  2. create requires a new nonempty id and a nonblank title; body is a string. Create a document with version 1.
  3. update and delete require an existing id and an exact expectedVersion. Reject stale versions with conflict.
  4. update replaces title and body and increases version by 1. delete removes only that document. Preserve list order, return unchanged documents on errors, and never mutate input.

Exercises

AI-assisted Coding9 exercises