Edit Documents

Open inAnthropic

Prerequisites

  • TerminusDB running locally (install guide)
  • A connected client instance with existing documents

What you'll achieve By the end of this guide, you will have updated existing documents in your TerminusDB database using the JavaScript client, the Python client, or the HTTP API.

To update a document, first retrieve it, make your changes, then submit the update. The document must include its @id and @type so TerminusDB knows which record to replace.

Update a document

Example: TypeScript
const doc = {
    "@id"   : "Player/George",
    "@type" : "Player",
    name    : "George",
    position: "Center Back",
}

doc.position = "Full Back"

const updateDoc = async () => {
  const result = await client.updateDocument(doc)
  console.log("Updated document:", result)
}

The update operation replaces the entire document. Include all fields — any field omitted from the update payload will be removed from the stored document.

Next steps

You've updated documents in TerminusDB. From here you can:

Was this helpful?