Updating

Update is very similar to insert:

import cats.data.NonEmptyVector
import doobie.*
import doobie.implicits.*


sql"""
${Users.updateTable(
  Users.firstName --> "John",
  Users.lastName --> "Doe"
)} WHERE ${Users.id === 42}
"""
// res0: Fragment = Fragment("
//       UPDATE users SET first_name = ?, last_name = ? WHERE id = ?
//       ")

// Or using a collection:
sql"""
${Users.updateTable(NonEmptyVector.of(
  Users.firstName --> "John",
  Users.lastName --> "Doe"
))} WHERE ${Users.id === 42}
"""
// res1: Fragment = Fragment("
//       UPDATE users SET first_name = ?, last_name = ? WHERE id = ?
//       ")

You can use the composite columns as well:

import cats.data.NonEmptyVector
import doobie.*
import doobie.implicits.*

sql"""
${Users.updateTable(Users.Names ==> Users.Names("John", "Doe", Some("Fast Johnny")))}
WHERE ${Users.id === 42}
"""
// res2: Fragment = Fragment("
//       UPDATE users SET first_name = ?, last_name = ?, nickname = ?
//       WHERE id = ?
//       ")