Selecto.Configuration
(Selecto v0.4.5)
Copy Markdown
Domain configuration and initialization for Selecto.
This module handles the setup and configuration of Selecto instances, including domain validation, connection pooling, and adapter initialization.
Summary
Functions
Generate a selecto structure from a domain configuration and connection input.
Generate the selecto configuration from a domain map.
Configure Selecto from an Ecto repository and schema.
Functions
@spec configure(Selecto.Types.domain(), term(), keyword()) :: Selecto.Types.t()
Generate a selecto structure from a domain configuration and connection input.
Parameters
domain- Domain configuration map (see domain configuration docs)postgrex_opts- Connection input retained for backward compatibility. This may be adapter-specific connection options, an Ecto repo, a live connection pid/name, or a pooled connection reference.opts- Configuration options
Options
:validate- (boolean, default: true) Whether to validate the domain configuration:pool- (boolean, default: false) Whether to enable connection pooling:pool_options- Connection pool configuration options:adapter- (module, default:SelectoDBPostgreSQL.Adapter) Database adapter module:rollup_sort_fix- (true | false | :auto, default::auto) whether to wrapGROUP BY ROLLUP ... ORDER BYqueries in a compatibility subquery;:autodisables the wrapper on PostgreSQL 18+
Examples
# Basic usage (validation enabled by default)
selecto = Selecto.Configuration.configure(domain, connection_input)
# With connection pooling
selecto = Selecto.Configuration.configure(domain, connection_input, pool: true)
# Disable validation for performance
selecto = Selecto.Configuration.configure(domain, connection_input, validate: false)
@spec configure_domain(Selecto.Types.domain()) :: Selecto.Types.processed_config()
Generate the selecto configuration from a domain map.
Processes domain configuration to extract fields, joins, and filters. This is called internally during configure/3.
@spec configure_domain(Selecto.Types.domain(), [{module(), keyword()}]) :: Selecto.Types.processed_config()
@spec from_ecto(module(), module(), keyword()) :: Selecto.Types.t()
Configure Selecto from an Ecto repository and schema.
This convenience function automatically introspects the Ecto schema and configures Selecto with the appropriate domain and database connection.
Parameters
repo- The Ecto repository module (e.g., MyApp.Repo)schema- The Ecto schema module to use as the source tableopts- Configuration options (passed to EctoAdapter.configure/3)
Examples
# Basic usage
selecto = Selecto.Configuration.from_ecto(MyApp.Repo, MyApp.User)
# With joins and options
selecto = Selecto.Configuration.from_ecto(MyApp.Repo, MyApp.User,
joins: [:posts, :profile],
redact_fields: [:password_hash]
)