A Command is a default-exported TypeScript function under
commands/ or apps/<app>/commands/.
import { db, sql } from "worldant"
export default async function open(input) {
return db.many(sql`select * from todo_items where done = false order by id`)
}
Commands do not receive a context argument. They import supported
capabilities from worldant.
Standalone db.one, db.many, and
db.exec operations each use an independent database
transaction. If the Command later throws, earlier standalone
commits remain committed.
Use db.transaction(callback) when several Command
database operations must commit atomically:
await db.transaction(async (tx) => {
await tx.exec(sql`update todo_items set done = true where id = ${input.id}`)
return tx.one(sql`select * from todo_items where id = ${input.id}`)
})
Only tx.* calls enlist in the explicit transaction.
Plain db.* calls inside the callback remain
independent.
