Constructs a HyperdriveBinding instance.
Optionalsettings: HyperdriveSettings
Resolved settings. Defaults to resolve('hyperdrive'), so callers
normally construct this with no arguments at all.
The binding name this instance resolves.
The binding name as declared in wrangler.json.
Opens a raw TCP socket to the database through Hyperdrive.
The socket is unauthenticated — the driver is expected to authenticate using HyperdriveBinding.credentials.
The Worker environment.
The connected socket.
Returns a connection string for the pooled database.
The Worker environment.
A connection string accepted by the usual drivers and ORMs.
The credentials in this string are scoped to the running Worker instance — never log it or hand it to a client.
MissingBindingError When the Hyperdrive binding is absent.
Returns the connection details as discrete fields.
Use this with drivers that take a credentials object rather than a URL.
The Worker environment.
The host, port, user, password, and database name.
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.
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.
Resolves the binding without throwing.
The Worker environment.
The resolved binding, or null when it is not configured.
Accessor for the Hyperdrive binding (
hyperdriveinwrangler.json), which pools and caches connections to an external SQL database.Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.0.0