Represents the result of a database query or command.
This struct contains all information returned from a successful database operation, including column names, result rows, and metadata about the operation performed.
Fields
:command- The type of SQL command (:select,:insert,:update,:delete,:create,:begin,:commit,:rollback,:pragma,:batch,:unknown,:other, ornil):columns- List of column names (for SELECT queries), ornilfor write operations:rows- List of rows, where each row is a list of values, ornilfor write operations:num_rows- Number of rows affected or returned
Examples
# SELECT result
%EctoLibSql.Result{
command: :select,
columns: ["id", "name"],
rows: [[1, "Alice"], [2, "Bob"]],
num_rows: 2
}
# INSERT/UPDATE/DELETE result (without RETURNING)
%EctoLibSql.Result{
command: :insert,
columns: nil,
rows: nil,
num_rows: 1
}
Summary
Functions
Creates a new Result struct from a keyword list of options.
Types
@type command_type() ::
:select
| :insert
| :update
| :delete
| :batch
| :create
| :begin
| :commit
| :rollback
| :pragma
| :unknown
| :other
| nil
The type of SQL command that was executed.
@type t() :: %EctoLibSql.Result{ columns: [String.t()] | nil, command: command_type(), num_rows: non_neg_integer(), rows: [[term()]] | nil }
Result struct containing query results.
Functions
Creates a new Result struct from a keyword list of options.
Options
:command- The command type (default::other):columns- List of column names (default:nil):rows- List of rows (default:nil):num_rows- Number of rows (default:0)
Examples
iex> EctoLibSql.Result.new(command: :select, columns: ["id"], rows: [[1]], num_rows: 1)
%EctoLibSql.Result{command: :select, columns: ["id"], rows: [[1]], num_rows: 1}