function update
update(
table: string,
set: Record<string, InValue | RawSql>,
where: Record<string, InValue>,
): SqlStatement

Build an UPDATE statement from a table name, a column→value record for the SET clause, and a column→value record for the WHERE clause (equality checks, ANDed together). The counterpart of insert — use it instead of hand-writing the UPDATE … SET … WHERE … string when every condition is a plain column = value match; a write that needs a richer guard (IS NULL, an inequality, a subquery) keeps its own SQL. SET values may be rawSql expressions (e.g. a counter increment).

update("attendees", { pii_blob: encrypted }, { id: 4 })
// → { sql: "UPDATE attendees SET pii_blob = ? WHERE id = ?",
//     args: [encrypted, 4] }

update(
  "listing_attendees",
  { attachment_downloads: rawSql("attachment_downloads + 1") },
  { attendee_id: 1, listing_id: 2 },
)
// → { sql: "UPDATE listing_attendees SET attachment_downloads = attachment_downloads + 1
//           WHERE attendee_id = ? AND listing_id = ?", args: [1, 2] }

Parameters

table: string
set: Record<string, InValue | RawSql>
where: Record<string, InValue>

Return Type

Usage

import { update } from "docs/database.ts";