Maintains the connection state for a LibSQL database connection.
This struct tracks the current connection state including the connection ID, active transaction ID (if any), connection mode, and sync settings.
Fields
:conn_id- Unique identifier for the connection (required):trx_id- Transaction ID if a transaction is active,nilotherwise:mode- Connection mode (:local,:remote, or:remote_replica):sync- Sync mode for replicas (:enable_syncor:disable_sync)
Connection Modes
:local- Local SQLite file:remote- Direct connection to remote Turso database:remote_replica- Local SQLite file with remote sync enabled
Summary
Types
Connection mode for LibSQL database connections.
Sync mode for replica connections.
Connection state struct.
Functions
Detects the connection mode based on provided options.
Detects the sync mode based on provided options.
Types
@type mode() :: :local | :remote | :remote_replica | :unknown
Connection mode for LibSQL database connections.
@type sync_mode() :: :enable_sync | :disable_sync
Sync mode for replica connections.
@type t() :: %EctoLibSql.State{ conn_id: String.t(), mode: mode() | nil, sync: sync_mode() | nil, trx_id: String.t() | nil }
Connection state struct.
Functions
Detects the connection mode based on provided options.
Examples
iex> EctoLibSql.State.detect_mode(database: "local.db")
:local
iex> EctoLibSql.State.detect_mode(uri: "libsql://...", auth_token: "...")
:remote
iex> EctoLibSql.State.detect_mode(database: "local.db", uri: "libsql://...", auth_token: "...", sync: true)
:remote_replica
Detects the sync mode based on provided options.
Returns :enable_sync if sync is explicitly set to true,
:disable_sync otherwise.
Examples
iex> EctoLibSql.State.detect_sync(sync: true)
:enable_sync
iex> EctoLibSql.State.detect_sync(sync: false)
:disable_sync
iex> EctoLibSql.State.detect_sync([])
:disable_sync