CloudflareD1Providerclass

new CloudflareD1Provider<I, T>(db: D1Database)
ParamType
dbD1Database
The D1Database binding from the Worker environment. required
Return
CloudflareD1Provider<I, T>
SQLite database provider backed by Cloudflare D1.

SQLite database provider backed by Cloudflare D1.

Implements the SQLiteProvider SQL abstraction by binding tagged-template queries and running them through the D1 Worker API.

  • Tagged-template values are flattened into positional ? bindings; nested SQLFragment values are inlined recursively.
  • Array and plain-object values are JSON-encoded before binding; other non-primitive values throw ValueError.
  • The D1Database binding is provided by the Cloudflare Workers runtime environment.

Examples

// `env.DB` is the D1 binding from the Worker environment.
const provider = new CloudflareD1Provider(env.DB);