Function: fromD1()
Function: fromD1()
Section titled “Function: fromD1()”fromD1(
d1):SqlExecutor
Defined in: server/src/adapters/d1.ts:18
Wrap a Cloudflare D1Database binding as a SqlExecutor.
D1 does not support classic BEGIN/COMMIT — transactions are expressed via
db.batch([...stmts]) which executes atomically. To honour the async
transaction(fn) contract we collect statements in a queue during fn
and dispatch them as a single batch() on commit.
This is a functional but naive implementation:
all()inside a transaction runs immediately (not batched); mixing reads and writes in one tx therefore can’t see the tx’s own writes until commit. For the sync handler’s use case (read state → decide → write) that is fine, but it is a limitation to remember.
Parameters
Section titled “Parameters”D1Database