Selecto.Configuration (Selecto v0.3.8)

Domain configuration and initialization for Selecto.

This module handles the setup and configuration of Selecto instances, including domain validation, connection pooling, and adapter initialization.

Link to this section Summary

Functions

Generate a selecto structure from a domain configuration and database connection.

Generate the selecto configuration from a domain map.

Configure Selecto from an Ecto repository and schema.

Link to this section Functions

Link to this function

configure(domain, postgrex_opts, opts \\ [])

Generate a selecto structure from a domain configuration and database connection.

parameters

Parameters

  • domain - Domain configuration map (see domain configuration docs)
  • postgrex_opts - Postgrex connection options, PID, or pooled connection
  • opts - Configuration options

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: Selecto.DB.PostgreSQL) Database adapter module
  • :rollup_sort_fix - (true | false | :auto, default: :auto) whether to wrap GROUP BY ROLLUP ... ORDER BY queries in a compatibility subquery; :auto disables the wrapper on PostgreSQL 18+

examples

Examples

# Basic usage (validation enabled by default)
selecto = Selecto.Configuration.configure(domain, postgrex_opts)

# With connection pooling
selecto = Selecto.Configuration.configure(domain, postgrex_opts, pool: true)

# Disable validation for performance
selecto = Selecto.Configuration.configure(domain, postgrex_opts, validate: false)
Link to this function

configure_domain(domain)

@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.

Link to this function

configure_domain(domain, extension_specs)

@spec configure_domain(Selecto.Types.domain(), [{module(), keyword()}]) ::
  Selecto.Types.processed_config()
Link to this function

from_ecto(repo, schema, opts \\ [])

@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

Parameters

  • repo - The Ecto repository module (e.g., MyApp.Repo)
  • schema - The Ecto schema module to use as the source table
  • opts - Configuration options (passed to EctoAdapter.configure/3)

examples

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]
)