Constructs a D1Binding instance.
Optionalsettings: D1Settings
Resolved settings. Defaults to resolve('d1'), so callers
normally construct this with no arguments at all.
The binding name this instance resolves.
The binding name as declared in wrangler.json.
Runs a query and returns every row.
The Worker environment.
SQL statement, using ? placeholders for bind values.
Values bound to the placeholders, in order.
The matched rows, empty when the query matched nothing.
Runs several prepared statements in a single batch.
Statements execute in order and are wrapped in an implicit transaction, so a failure rolls the whole batch back.
The Worker environment.
Statements built via D1Binding.prepare.
One result per statement, in the order supplied.
Executes raw SQL, typically a migration or a multi-statement script.
The Worker environment.
One or more SQL statements separated by newlines.
The execution summary, including the number of statements run.
This path does not support bind values — never build a statement here from user input. Use D1Binding.run for anything parameterised.
Runs a query and returns the first row.
The Worker environment.
SQL statement, using ? placeholders for bind values.
Values bound to the placeholders, in order.
The first matched row, or null when the query matched nothing.
Checks whether the binding is available on the given environment.
Use this to degrade gracefully when a binding is optional.
The Worker environment.
true when the binding is present.
Prepares a statement, binding the supplied values when any are given.
The Worker environment.
SQL statement, using ? placeholders for bind values.
Values bound to the placeholders, in order.
The prepared statement, ready to run.
MissingBindingError When the D1 binding is absent.
Resolves the binding, failing fast when it is not configured.
The Worker environment.
The resolved binding.
MissingBindingError When the binding is absent from the environment.
Runs a write statement and returns its execution metadata.
The Worker environment.
SQL statement, using ? placeholders for bind values.
Values bound to the placeholders, in order.
The D1 result, including meta.changes and meta.last_row_id.
Resolves the binding without throwing.
The Worker environment.
The resolved binding, or null when it is not configured.
Accessor for the D1 database binding (
d1_databasesinwrangler.json).Every query helper takes the statement and its bind values separately, so user input is always parameterised rather than interpolated into SQL.
Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.0.0