コンテンツにスキップ

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.

D1Database

SqlExecutor