Cloudflare D1 icon

Cloudflare D1

Execute operations against Cloudflare D1 serverless databases. Supports structured operations (Insert, Select, Update, Delete), raw SQL queries, and can be used as a tool by AI Agents.

Table → Update

AI-generated

Summary

Update rows in a Cloudflare D1 table matching WHERE conditions, setting specified column values.

Inputs

  • databaseId (required) — The unique identifier of the Cloudflare D1 database.
  • table (required) — The name or identifier of the table to update.
  • updateFields (required) — Array of column updates; each entry defines a column name and its new value.
  • whereUpdate — Array of WHERE conditions; each defines a column, operator, and value to filter rows.

Output shape

object indicating success and metadata about rows affected (rowsWritten, changes); includes success flag, results array, meta object.

The returned object contains a success boolean, an array of updated rows, and metadata fields rowsWritten and changes; results may be empty.

Examples

Example 1: Update user status to active where id equals 5

databaseId: "123", table: "users", updateFields: [{column: "status", value: "active"}], whereUpdate: [{column: "id", operator: "=", value: "5"}]

Example 2: Set price to 100 for all products in stock

databaseId: "456", table: "products", updateFields: [{column: "price", value: "100"}], whereUpdate: [{column: "inStock", operator: "=", value: "true"}]

Example 3: Increment viewCount for a specific article

databaseId: "789", table: "articles", updateFields: [{column: "viewCount", value: "{{ $JSON.viewCount + 1 }}"}] , whereUpdate: [{column: "slug", operator: "=", value: "node-example"}]

Discussion