package wasm-sql:core@0.1.0;
/// Common types used across all wasm-sql interfaces.
/// Contains error types and basic SQL primitives.
interface util-types {
/// Errors that can occur during SQL operations.
variant error {
/// Error occurred while encoding a value to SQL format.
encode(string),
/// Error occurred while decoding a value from SQL format.
decode(string),
/// Connection pool timed out while waiting for an available connection.
pool-timed-out,
/// Attempted to acquire a connection from a closed pool.
pool-closed,
/// Failed to begin a transaction due to unexpected connection state.
begin-failed,
/// Attempted to perform operation on an already closed or committed transaction.
transaction-closed,
/// Generic unexpected error with description.
unexpected(string)
}
}
/// Types for constructing and executing SQL queries.
interface query-types {
/// Raw SQL query string.
type sql-string = string;
/// A prepared SQL query with optional arguments and caching settings.
record sql-query {
/// The SQL query string with parameter placeholders ($1, $2, etc.).
sql: sql-string,
/// Optional arguments to bind to the query parameters.
args: option<sql-arguments>,
/// If true or none, the prepared statement will be cached for reuse.
persistent: option<bool>,
}
/// Container for SQL query arguments.
/// Use database-specific codec functions to push values.
resource sql-arguments {
/// Creates a new empty arguments container.
constructor();
}
/// Results returned from a SELECT query.
/// Use database-specific codec functions to extract values.
resource query-results {
/// Returns the number of rows in the result set.
row-count: func() -> u64;
}
}