Update

Use update() to modify an existing document by its ID. Only the fields you pass will be updated — the rest stay untouched.

✏️ update()

await db.users.update("user_gilfoyle", {
  name: "Bertram Gilfoyle",
  isAdmin: true,
});

This updates just the name and isAdmin fields of the document with _id: "user_gilfoyle".

Behavior

  • Partial update: You don't need to pass all fields.
  • Schema validated: The new fields are still validated against the schema.
  • updatedAt is automatically updated for you.