Skip to content

Update

update() modifies matching rows. Pair it with where() to scope the update.

await db.from(users).where("id", "=", 1).update({ age: 37 });

Omit where() to update every row:

await db.from(users).update({ active: true });
const { rows } = await db
.from(users)
.where("id", "=", 1)
.returning("email")
.update({ age: 37 });
db.from(users).where("id", "=" , 1).update({ age: 37 });
// → UPDATE "users" SET "age" = ? WHERE "id" = ?
export async function renameUser(id: number, email: string) {
await db.from(users).where("id", "=", id).update({ email });
}
  • Always add where() unless you mean to update the whole table.
  • Use returning() to confirm what changed.
  • Bind values — MountSQLI never interpolates them.
  • Forgetting where() and updating all rows.
  • Reusing a builder after a terminal call expecting more chaining.