CloudflareD1Providerclass
new CloudflareD1Provider<I, T>(db: D1Database)
| Param | Type | |
|---|---|---|
db | D1Database | 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; nestedSQLFragmentvalues are inlined recursively. - Array and plain-object values are JSON-encoded before binding; other non-primitive values throw
ValueError. - The
D1Databasebinding 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);