skip to content
$worker

database

v0.5.2

Talk to PostgreSQL, MySQL, and SQLite from iii — query, execute, transactions, prepared statements, and change feeds.

iiiverified
1,102 installs92 in 7d0 today
install
$iii trigger compose::add worker=database@0.5.2
binarylicense: Apache-2.0dbmysqlpostgressqlsqlite
  • macOS: arm64 · x64
  • Linux: arm64 · armv7 · x64
  • Windows: arm64 · x64 · x86

exact versions are immutable; binary and bundle artifacts are digest-pinned.

functions

30

database::beginTransaction

function

Open an interactive transaction; returns a handle to use with transactionQuery/transactionExecute/commitTransaction/rollbackTransaction.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • isolationstring
  • timeout_msinteger· uint64min 0
response
  • transactionobjectrequired

    JSON wire envelope returned by `beginTransaction`.

    • expires_atstring· date-timerequired
    • idstringrequired

database::browseTable

function

Read a table page by page with typed filters and sorts, without writing SQL. Filters are structured (column, op, value) and compile to a parameterised WHERE for the driver in hand; the total honours the same filters. Use an equality filter at page_size 1 to follow a foreign key.

request
  • dbstring
  • filtersobject[]

    Combined with AND.

    • case_sensitiveboolean

      Postgres only. Rejected elsewhere rather than silently ignored.

    • columnstringrequired
    • disabledboolean

      Kept in the list but not applied. A caller refining a query wants to switch one condition off and back on without losing how it was built, and a console that only offers delete makes that a retype.

    • opone ofrequired
      one of (4)
      variant 1
      valuestringenum: contains, not_contains, equals, not_equals, starts_with, ends_with,
      variant 2
      valuestringenum: between
      variant 3
      valuestringenum: is_empty
      variant 4
      valuestringenum: in
    • valueunknown
    • value2unknown

      Upper bound for `between`.

    • valuesunknown[]

      Operands for `in` / `not_in`.

  • include_totalboolean

    A filtered `COUNT(*)` is a second query and can be expensive on a large table. Turn it off while the caller is still typing.

  • pageinteger· uint32min 0

    Zero-based.

  • page_sizeinteger· uint32min 0
  • schemastring
  • sortobject[]

    Applied in order; sort priority is position in the list.

    • columnstringrequired
    • directionall of
      all of (1)
      variant 1
      valuestringenum: asc, desc
    • modeall of
      all of (1)
      variant 1
      one of (2)
      variant 1
      valuestringenum: default, length, absolute_value, random
      variant 2
      valuestringenum: natural
    • nullsany of
      any of (2)
      variant 1
      valuestringenum: first, last
      variant 2
      valuenull
  • tablestringrequired
  • timeout_msinteger· uint64min 0
response
  • columnsobject[]required
    • namestringrequired
    • typestringrequired
  • has_morebooleanrequired

    Derived from a sentinel row, so it is correct without a count.

  • pageinteger· uint32requiredmin 0
  • page_sizeinteger· uint32requiredmin 0
  • rowsobject[]required
    empty object
  • totalinteger· int64

    Total matching the same filters. Absent when not requested.

database::columnStats

function

Profile a table's columns. Reads the planner's own statistics by default, which is free and approximate; `exact` runs real aggregates and scans the table. To profile rows you already hold, pipe a browseTable result through the fp worker instead.

request
  • columnsstring[]

    Omit to profile every column.

  • dbstring
  • exactboolean

    Run real aggregates instead of reading planner statistics. This scans the table.

  • schemastring
  • tablestringrequired
  • timeout_msinteger· uint64min 0
  • top_ninteger· uintmin 0
response
  • approximatebooleanrequired

    True when the numbers came from the planner rather than a count.

  • columnsobject[]required
    • distinct_countinteger· int64
    • maxunknown
    • meannumber· double
    • minunknown
    • namestringrequired
    • null_countinteger· int64
    • null_fractionnumber· double
    • row_countinteger· int64
    • sourceone ofrequired
      one of (2)
      variant 1
      valuestringenum: planner
      variant 2
      valuestringenum: computed
    • top_valuesobject[]required

      Only populated in `exact` mode; the planner's own most-common-value lists are not portable enough to report faithfully.

      • countinteger· int64required
      • valueunknownrequired
  • schemastring
  • tablestringrequired

database::commitTransaction

function

Commit and finalize an interactive transaction.

request
  • transaction_idstringrequired
response
  • committedbooleanrequired

database::deleteSavedQuery

function

Delete a saved query by id or by name.

request
  • dbstring
  • idstringrequired

    Either the id returned by `saveQuery`, or the name it was saved under.

response
  • deletedbooleanrequired

database::describeSchema

function

Describe every table at once — the same shape as describeTable, but one catalog query per aspect across the whole database instead of one call per table. Use this to reason about relationships; set include_indexes only when you need them.

request
  • dbstring
  • include_indexesboolean

    Indexes cost one extra catalog query. Off by default because the common caller (a relationship diagram) only needs columns and keys.

  • max_tablesinteger· uintmin 0
  • tablesstring[]

    Restrict to these tables. Omit for every table in the database.

  • timeout_msinteger· uint64min 0
response
  • countinteger· uintrequiredmin 0
  • tablesobject[]required
    • columnsobject[]required
      • default_valuestring
      • foreign_keyany of
        … expand 2 nested
        any of (2)
        variant 1
        • columnstringrequired
        • schemastring
        • tablestringrequired
        variant 2
        valuenull
      • namestringrequired
      • nullablebooleanrequired
      • positioninteger· int32required

        1-based ordinal, as the driver reports it.

      • primary_keybooleanrequired
      • typestringrequired

        Driver-reported type text (`TEXT`, `integer`, `varchar(255)`).

    • indexesobject[]required
      • columnsstring[]required

        Indexed columns in ordinal order. Empty when the index is on an expression rather than plain columns.

      • namestringrequired
      • primarybooleanrequired
      • uniquebooleanrequired
    • kindstringrequiredenum: table, view
    • row_count_estimateinteger· int64

      Planner estimate, never a `COUNT(*)`. Absent when the driver has no cheap estimate (sqlite) or has not analyzed the table yet.

    • schemastring
    • tablestringrequired
  • truncatedbooleanrequired

    True when `max_tables` cut the result short. Never silently truncate.

database::describeTable

function

Describe one table or view: columns with type, nullability, default, primary-key membership and foreign-key target; plus indexes and a planner row estimate. Foreign keys are structured (schema, table, column), not a joined string.

request
  • dbstring
  • schemastring
  • tablestringrequired

    Table or view name. May be schema-qualified (`analytics.events`) on postgres; prefer the explicit `schema` field when the name itself contains a dot.

  • timeout_msinteger· uint64min 0
response
  • columnsobject[]required
    • default_valuestring
    • foreign_keyany of
      any of (2)
      variant 1
      • columnstringrequired
      • schemastring
      • tablestringrequired
      variant 2
      valuenull
    • namestringrequired
    • nullablebooleanrequired
    • positioninteger· int32required

      1-based ordinal, as the driver reports it.

    • primary_keybooleanrequired
    • typestringrequired

      Driver-reported type text (`TEXT`, `integer`, `varchar(255)`).

  • indexesobject[]required
    • columnsstring[]required

      Indexed columns in ordinal order. Empty when the index is on an expression rather than plain columns.

    • namestringrequired
    • primarybooleanrequired
    • uniquebooleanrequired
  • kindstringrequiredenum: table, view
  • row_count_estimateinteger· int64

    Planner estimate, never a `COUNT(*)`. Absent when the driver has no cheap estimate (sqlite) or has not analyzed the table yet.

  • schemastring
  • tablestringrequired

database::execute

function

Run a write statement (INSERT/UPDATE/DELETE/DDL).

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • paramsunknown[]
  • returningstring[]
  • sqlstringrequired
response
  • affected_rowsinteger· uint64requiredmin 0
  • last_insert_idstring
  • returned_rowsobject[]required
    empty object

database::executeBatch

function

Run an ordered batch of SQL statements atomically (bare strings or {sql, params} objects); rolls back on first failure.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • isolationstring

    Optional: `read_committed` | `repeatable_read` | `serializable`.

  • statementsany of[]required

    Statements to run in order inside one transaction. Each entry is either a bare SQL string or `{ "sql": "...", "params": [...] }` — use `params` for dynamic values instead of inlining them into the SQL.

    any of (2)
    variant 1
    valuestring
    variant 2
    • paramsunknown[]
    • sqlstringrequired
response
  • committedbooleanrequired
  • errorunknown
  • failed_indexinteger· uintmin 0
  • resultsobject[]
    • affected_rowsinteger· uint64requiredmin 0
    • rowsunknown[][]required

database::explain

function

Return a statement's query plan as a tree with per-node costs, row estimates and warnings, instead of the driver's raw text. `analyze` collects real timings by RUNNING the statement, so it defaults to false and is refused for anything that is not a single read.

request
  • analyzeboolean

    Runs the statement to collect real timings. Refused for anything that is not a read.

  • dbstring
  • paramsunknown[]
  • sqlstringrequired
  • timeout_msinteger· uint64min 0
response
  • analyzedbooleanrequired
  • formatstringrequiredenum: pg_json, sqlite_query_plan, mysql_json, unknown
  • rawunknown

    The driver's own output, so a caller is never stuck when the shape is one we do not recognise.

  • rootany of
    any of (2)
    variant 1
    • childrenunknown[]required
    • cost_startupnumber· double
    • cost_totalnumber· double
    • detailstringrequired
    • idinteger· uint32requiredmin 0
    • labelstringrequired
    • loopsnumber· double
    • node_classstringrequiredenum: scan, index, join, sort, aggregate, cte,
    • parentinteger· uint32min 0
    • relationstring
    • rows_actualnumber· double
    • rows_estimatednumber· double
    • time_msnumber· double
    • widthinteger· int64
    variant 2
    valuenull
  • warningsobject[]required
    • kindone ofrequired
      one of (3)
      variant 1
      valuestringenum: seq_scan_large
      variant 2
      valuestringenum: estimate_skew
      variant 3
      valuestringenum: nested_loop_large
    • messagestringrequired
    • node_idinteger· uint32requiredmin 0
    • severitystringrequiredenum: info, warn

database::getTableView

function

How a table is laid out for reading: column widths, hidden columns and column order. Stored in the state worker rather than a browser, so it survives a restart and any caller can set it up for someone else.

request
  • dbstring
  • tablestringrequired
response
  • hiddenstring[]

    Columns the reader has hidden. Order is not meaningful.

  • orderstring[]

    Column display order. Names not listed keep their natural position after those that are, so adding a column to the table does not require re-saving the view.

  • widthsobject

    Per-column pixel width. Absent means "size to content".

database::health

function

Live pool occupancy plus active queries, table sizes, blocking locks and cache hit ratio. Each section reports separately as available, unsupported or denied, so a driver gap or a restricted role is never mistaken for an empty result.

request
  • dbstring
  • timeout_msinteger· uint64min 0
response
  • active_queriesone ofrequired

    One section of the report.

    one of (3)
    variant 1
    • dataobject[]required
      … expand 5 nested
      • duration_msinteger· int64
      • idstringrequired
      • sqlstringrequired
      • statestring
      • userstring
    • statusstringrequiredenum: available
    variant 2
    • reasonstringrequired
    • statusstringrequiredenum: unsupported
    variant 3
    • reasonstringrequired
    • statusstringrequiredenum: denied
  • cacheone ofrequired

    One section of the report.

    one of (3)
    variant 1
    • dataobjectrequired
      … expand 3 nested
      • blocks_hitinteger· int64required
      • blocks_readinteger· int64required
      • hit_rationumber· doublerequired

        Fraction of block reads served from cache. A healthy OLTP database usually sits well above 0.99.

    • statusstringrequiredenum: available
    variant 2
    • reasonstringrequired
    • statusstringrequiredenum: unsupported
    variant 3
    • reasonstringrequired
    • statusstringrequiredenum: denied
  • dbstringrequired
  • driverstringrequired
  • locksone ofrequired

    One section of the report.

    one of (3)
    variant 1
    • dataobject[]required
      … expand 5 nested
      • blocked_idstringrequired
      • blocked_sqlstringrequired
      • blocking_idstringrequired
      • blocking_sqlstring
      • relationstring
    • statusstringrequiredenum: available
    variant 2
    • reasonstringrequired
    • statusstringrequiredenum: unsupported
    variant 3
    • reasonstringrequired
    • statusstringrequiredenum: denied
  • poolobjectrequired

    Live pool occupancy, for `database::health`. `size` and `idle` are `None` where the underlying pool does not expose them — `mysql_async` keeps its counters private. Reporting `None` rather than zero matters: "unknown" and "no idle connections" are different answers, and a health panel that conflates them is actively misleading.

    • idleinteger· uint32min 0
    • maxinteger· uint32requiredmin 0
    • sizeinteger· uint32min 0
    • waitinginteger· uint32min 0
  • table_sizesone ofrequired

    One section of the report.

    one of (3)
    variant 1
    • dataobject[]required
      … expand 5 nested
      • index_bytesinteger· int64
      • row_estimateinteger· int64
      • schemastring
      • tablestringrequired
      • total_bytesinteger· int64
    • statusstringrequiredenum: available
    variant 2
    • reasonstringrequired
    • statusstringrequiredenum: unsupported
    variant 3
    • reasonstringrequired
    • statusstringrequiredenum: denied
  • worker_versionstringrequired

database::history

function

Recent queries run against a database, newest first. Best effort — recording never blocks or fails a query, so this is a convenience rather than an audit log. For an audit trail bind database::row-changed.

request
  • dbstring
  • limitinteger· uintmin 0
response
  • countinteger· uintrequiredmin 0
  • entriesobject[]required
    • atstringrequired
    • duration_msinteger· uint64min 0
    • row_countinteger· uintmin 0
    • sqlstringrequired
    • verbstringrequired

database::listDatabases

function

List all configured databases with connection details (driver, credential-redacted URL, pool settings, TLS mode). Config only — no health checks or live pool statistics.

request
empty object
response
  • countinteger· uintrequiredmin 0
  • databasesobject[]required
    • driverstringrequired

      "postgres" | "mysql" | "sqlite".

    • namestringrequired

      Logical key (e.g. "primary").

    • poolobjectrequired

      Pool settings echoed back from config (no live stats).

      • acquire_timeout_msinteger· uint64requiredmin 0
      • idle_timeout_msinteger· uint64requiredmin 0
      • maxinteger· uint32requiredmin 0
    • tlsobjectrequired

      TLS settings. `ca_cert` is reported as a presence boolean only — never the path, which would leak filesystem layout.

      • ca_cert_presentbooleanrequired
      • modeone ofrequired
        … expand 3 nested
        one of (3)
        variant 1
        valuestringenum: disable
        variant 2
        valuestringenum: require
        variant 3
        valuestringenum: verify-full
      • trust_nativebooleanrequired
    • urlstringrequired

      Connection URL with credentials redacted.

database::listSavedQueries

function

List the saved queries for a database, sorted by name.

request
  • dbstring
response
  • countinteger· uintrequiredmin 0
  • queriesobject[]required
    • descriptionstring
    • idstringrequired
    • namestringrequired
    • saved_atstringrequired
    • sqlstringrequired

database::listTables

function

List every table and view in a database, with its kind and (on postgres) its schema. Reads the driver's own catalog, so no dialect-specific SQL is needed from the caller.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • timeout_msinteger· uint64min 0
response
  • countinteger· uintrequiredmin 0
  • tablesobject[]required
    • kindstringrequiredenum: table, view
    • namestringrequired
    • schemastring

database::on-config-change

function

Internal: reload connection pools from the authoritative configuration when it changes.

request
  • idstring

    Configuration id that changed (advisory; the handler re-fetches the value). Schema-only: kept to publish a typed request schema; the handler ignores it.

response
  • okbooleanrequired

database::prepareStatement

function

Prepare a parameterized statement once.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • sqlstringrequired
  • ttl_secondsinteger· uint64min 0
response
  • handleobjectrequired
    • expires_atstring· date-timerequired
    • idstringrequired

database::query

function

Run a read-only SQL query and return the result rows.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • paramsunknown[]
  • sqlstringrequired
  • timeout_msinteger· uint64min 0
response
  • columnsobject[]required
    • namestringrequired
    • typestringrequired
  • row_countinteger· uintrequiredmin 0
  • rowsobject[]required
    empty object

database::rollbackTransaction

function

Rollback and finalize an interactive transaction.

request
  • transaction_idstringrequired
response
  • rolled_backbooleanrequired

database::runStatement

function

Run a previously-prepared handle.

request
  • handle_idstringrequired
  • paramsunknown[]
response
  • columnsobject[]required
    • namestringrequired
    • typestringrequired
  • row_countinteger· uintrequiredmin 0
  • rowsobject[]required
    empty object

database::saveQuery

function

Save a named query against a database. Stored in the state worker, so it survives restarts and an agent can save one for a human to find in the console. Saving under an existing name replaces it.

request
  • dbstring
  • descriptionstring
  • namestringrequired
  • sqlstringrequired
response
  • idstringrequired
  • replacedbooleanrequired

database::saveTableView

function

Replace the stored layout for a table. Widths are clamped to a usable range; columns the table no longer has are kept rather than rejected, so a rename degrades to a missing width instead of an error.

request
  • dbstring
  • hiddenstring[]

    Columns the reader has hidden. Order is not meaningful.

  • orderstring[]

    Column display order. Names not listed keep their natural position after those that are, so adding a column to the table does not require re-saving the view.

  • tablestringrequired
  • widthsobject

    Per-column pixel width. Absent means "size to content".

response
  • savedbooleanrequired

database::schemaDiagram

function

Lay out the schema as a diagram: positioned table nodes and routed foreign-key edges, plus the hub degree of each table, the isolated tables, and the remaining edge crossings. Reads the whole catalog in a handful of queries rather than one per table.

request
  • dbstring
  • depthinteger· uintmin 0

    How many foreign-key hops out from `focus` to include. Ignored without one. 1 is the table and its direct relations.

  • focusstring

    Lay out only the neighbourhood of this table. A whole schema drawn at once answers "what exists"; it does not answer "what does this table touch", which is the question actually being asked most of the time. With a focus the diagram becomes explorable one hop at a time instead of a wall to be scanned.

  • include_viewsboolean
  • max_tablesinteger· uintmin 0
  • timeout_msinteger· uint64min 0
response
  • componentsobject[]required

    Connected groups, with the box that encloses each. A schema is usually several independent clusters rather than one graph, and saying so is most of what makes a large diagram readable — a reader can take in "four unrelated groups" at a glance instead of scanning for edges that are not there.

    • hnumber· doublerequired
    • hubstring

      The most-referenced table in the group, if it has more than one member.

    • indexinteger· uintrequiredmin 0

      Stable index, in layout order.

    • tablesstring[]required

      Member tables, by node id.

    • wnumber· doublerequired
    • xnumber· doublerequired
    • ynumber· doublerequired
  • crossingsinteger· uint32requiredmin 0

    Edge crossings remaining after ordering. Lower is a tidier diagram.

  • edgesobject[]required
    • fromstringrequired
    • from_columnstringrequired
    • pointsobject[]required

      Polyline, already routed. Anchored on the column row where the column is visible, on the node edge otherwise.

      • xnumber· doublerequired
      • ynumber· doublerequired
    • self_loopbooleanrequired
    • tostringrequired
    • to_columnstringrequired
  • focusstring

    Echoed when the caller asked for a neighbourhood rather than the whole schema.

  • frontierstring[]

    Tables one hop beyond what was drawn. Non-empty means there is more to expand into, which is the difference between a diagram that looks complete and one that says where it stops.

  • heightnumber· doublerequired
  • isolatedstring[]required

    Tables with no foreign keys at all, placed on a trailing shelf.

  • nodesobject[]required
    • columnsobject[]required
      • foreign_keybooleanrequired
      • namestringrequired
      • nullablebooleanrequired
      • primary_keybooleanrequired
      • typestringrequired
    • degreeinteger· uint32requiredmin 0

      Number of foreign keys touching this table, in or out. Renderers use it to emphasise hubs.

    • hnumber· doublerequired
    • hidden_columnsinteger· uintrequiredmin 0

      Columns not drawn because of `MAX_ROWS`.

    • rankinteger· uint32requiredmin 0
    • schemastring
    • tablestringrequired
    • wnumber· doublerequired
    • xnumber· doublerequired
    • ynumber· doublerequired
  • truncatedbooleanrequired
  • widthnumber· doublerequired

database::terminateQuery

function

Terminate a backend session, or cancel just its running statement with `cancel_only`. Takes an id from database::health. Separate from health because it is a write.

request
  • cancel_onlyboolean

    Ask the backend to cancel the running statement but keep the session. The default terminates the session outright.

  • dbstring
  • idstringrequired

    Backend pid (postgres) or connection id (mysql), as reported by `database::health`.

  • timeout_msinteger· uint64min 0
response
  • idstringrequired
  • terminatedbooleanrequired

database::testConnection

function

Probe a candidate database config (url + optional tls) with one throwaway connection, without touching configured pools. Reports ok/driver/latency/server version; failures are data, not errors.

request
  • timeout_msinteger· uint64min 0

    Overall budget for the attempt. Default 5000, capped at 30000.

  • tlsany of

    TLS settings to probe with. Defaults like a configured database (mode `require`) when omitted.

    any of (2)
    variant 1
    • ca_certstring

      Optional path to a PEM file containing one or more CA certificates. Additive by default — these certs **extend** the system trust store rather than replace it. Set `trust_native: false` for strict-isolation deployments that must only trust the operator-supplied bundle.

    • modeall of

      TLS mode: `disable` (plaintext), `require` (default), or `verify-full`.

      … expand 1 nested
      all of (1)
      variant 1
      one of (3)
      variant 1
      valuestringenum: disable
      variant 2
      valuestringenum: require
      variant 3
      valuestringenum: verify-full
    • trust_nativeboolean

      When true (default), the system/native trust store is loaded in addition to any `ca_cert` bundle. Set to `false` to trust only the `ca_cert` certificates — useful when an operator wants to pin trust to a private CA and explicitly *not* accept the public web PKI. Effective for postgres. MySQL is forced-additive: `mysql_async`'s rustls path always loads the Mozilla `webpki_roots` bundle and extends it with `ca_cert` — there is no upstream knob to suppress the bundled roots, so `trust_native: false` only affects postgres. Note: with both `trust_native: false` *and* `ca_cert: None` on postgres, no trust roots are available; pool construction fails with `CONFIG_ERROR`.

    variant 2
    valuenull
  • urlstringrequired

    Connection url to probe (`postgres://…`, `mysql://…`, `sqlite:…`).

response
  • driverstringrequired

    "postgres" | "mysql" | "sqlite" | "unknown".

  • latency_msinteger· uint64requiredmin 0

    Wall time of the whole attempt.

  • messagestring

    Why the probe failed (credentials scrubbed). Absent on success.

  • okbooleanrequired

    Whether a connection was established and answered a query.

  • server_versionstring

    Server version string, when the probe got far enough to ask.

database::transaction

function

Run a sequence of statements atomically.

request
  • dbstring

    Logical database name. Optional — omitting it targets the sole configured database, or `primary` when several are configured.

  • isolationstring
  • statementsobject[]required
    • paramsunknown[]
    • sqlstringrequired
response
  • committedbooleanrequired
  • errorunknown
  • failed_indexinteger· uintmin 0
  • resultsobject[]
    • affected_rowsinteger· uint64requiredmin 0
    • rowsunknown[][]required

database::transactionExecute

function

Run a write statement inside an interactive transaction. BEGIN/COMMIT/ROLLBACK are rejected; use commit/rollbackTransaction.

request
  • paramsunknown[]
  • returningstring[]
  • sqlstringrequired
  • transaction_idstringrequired
response
  • affected_rowsinteger· uint64requiredmin 0
  • last_insert_idstring
  • returned_rowsobject[]required
    empty object

database::transactionQuery

function

Run a read-only SQL query inside an interactive transaction.

request
  • paramsunknown[]
  • sqlstringrequired
  • transaction_idstringrequired
response
  • columnsobject[]required
    • namestringrequired
    • typestringrequired
  • row_countinteger· uintrequiredmin 0
  • rowsobject[]required
    empty object

database::ui-content

function

Serve the database worker's injected console UI assets (content function for its console:script / console:style triggers).

request
  • pathstringrequired

    The asset path from the trigger config (e.g. `state/page.js`).

response
  • contentstringrequired

    The asset source, verbatim.

  • content_typestringrequired

    MIME type the console should serve the asset with.

triggers

1

database::row-changed

trigger

Fires after this worker commits a row change, filtered by `db`, optional `table`, and optional `ops`. Reports only mutations made THROUGH this worker — not change data capture.

invocation
  • dbstringrequired

    Database handle, as named in the worker's config. Required — a binding that watched every database would fire for traffic its owner never asked about.

  • opsone of[]

    Operation filter. Omit to hear every operation.

    one of (2)
    variant 1
    valuestringenum: insert, update, delete
    variant 2
    valuestringenum: other
  • tablestring

    Table filter. Matched case-insensitively and ignoring a schema qualifier. Omit to hear every table in the database.

return
  • affected_rowsinteger· uint64requiredmin 0
  • atinteger· int64required

    Epoch millis at emit time.

  • dbstringrequired
  • opone ofrequired

    The kind of row change a statement makes.

    one of (2)
    variant 1
    valuestringenum: insert, update, delete
    variant 2
    valuestringenum: other
  • returningobject[]

    The `RETURNING` rows, when the caller asked for them. Absent otherwise — this trigger reports that a change happened, not the new row.

    empty object
  • tablestring

    `null` when the statement was recognisably a write but its table could not be read out of the SQL (a CTE-wrapped write, for example).