Skip to content

QueryDatabase

Source: src/Cloudflare/D1/QueryDatabase.ts

Bind a {@link Database} to a Worker and obtain the Effect-native D1 connection client (prepare, exec, batch, raw).

QueryDatabase is a single identifier that is simultaneously the binding’s Context tag, its type, and the callable — yield* Cloudflare.D1.QueryDatabase(db).

const db = yield* Cloudflare.D1.QueryDatabase(MyDatabase);
const rows = yield* db.prepare("SELECT * FROM users").all();