.compose/stage.db). When deployed, each Compose app gets its own fully isolated Postgres database. The API is identical in both environments.
The hosted Postgres is yours to use for application state via collections, but Compose also uses the same database internally to power durable execution (clean resumes after crashes and rolling deploys), transaction reorg monitoring, and wallet bookkeeping. Internal state lives in reserved namespaces — see Reserved collection names below.
Examples
Full Interface
collection function is available on TaskContext:
Filter operators
TheFilter type supports comparison operators beyond simple equality:
setById return value
setById defaults to upsert behavior. The return value tells you whether the write created a new row or updated an existing one:
upserted: false,matched: 0— the document did not exist, so a new row was inserted.upserted: true,matched: 1— an existing document with thatidwas updated.
{ upsert: false } to disable insert-on-missing; setById will then throw if no document exists with that id.
drop() vs deleteById()
collection.drop() runs DROP TABLE IF EXISTS against the backing database — it removes the collection’s table entirely, not just its rows. Subsequent calls like insertOne do not automatically recreate the table; you must call ctx.collection(name, indexes) again to recreate it (along with its indexes).
For routine cleanup that preserves the table and its indexes, prefer deleteById (or iterate with findMany + deleteById). Reach for drop() only when you truly want to discard the collection.
Reserved collection names
The following names are reserved for internal use and cannot be used as collection names:wallets, stage, monitored_transactions, runs, context_functions. Attempting to create or drop a collection with a reserved name throws an error.
Next Steps
EVM
Interact with EVM blockchains and smart contracts.
env
Set and access environment variables.