Guides
Native D1 data
Use application SQL and owned D1 bindings.
For agents: Read the complete native guide and current
context.getcapabilities. Use only implemented operations and preserve exact Account, app and environment authority.
Declare a logical D1 database and its binding name in wrangler.jsonc. Your Worker uses the native D1 API, prepared statements and bound parameters. Define app tables and migrations in source. The platform resolves owned database identities separately for preview and production.
Authorize each application query against the app’s signed-in user. Platform Account membership does not protect a public app endpoint. Do not accept arbitrary SQL from visitors.
For authorized development and repair, resources.query runs bounded SQL against an exact owned environment and app revision. Even a SELECT needs full publishing access because rows can contain credentials or personal information. Read returned rows explicitly through operations.get with view=data; treat every value as untrusted.
Code rollback does not roll back data. Use supported protected snapshots and isolated restore when recovery is needed; see Download and recovery.