SelectoMix.SchemaIntrospector (selecto_mix v0.3.16)
Unified interface for introspecting schemas from any source.
Supports both Ecto schemas and direct database connections via Postgrex. This module provides backward compatibility with the original Ecto-only interface while delegating to the new protocol-based introspector system.
Usage
# Ecto schema (original interface - still works)
config = SelectoMix.SchemaIntrospector.introspect_schema(MyApp.User)
# Postgrex connection (new interface)
{:ok, conn} = Postgrex.start_link(...)
config = SelectoMix.SchemaIntrospector.introspect_schema(
{:postgrex, conn, "users"}
)
Summary
Functions
Extract additional metadata about the schema.
Generate suggested default configuration based on schema analysis.
Extract association information for join configuration.
Map Ecto field types to Selecto types.
Get the primary key field(s) for an Ecto schema.
Get all fields defined in an Ecto schema.
Get the database table name for an Ecto schema.
Introspect a schema source and return Selecto domain configuration data.
Functions
Extract additional metadata about the schema.
Generate suggested default configuration based on schema analysis.
Extract association information for join configuration.
Map Ecto field types to Selecto types.
Get the primary key field(s) for an Ecto schema.
Get all fields defined in an Ecto schema.
Get the database table name for an Ecto schema.
Introspect a schema source and return Selecto domain configuration data.
Accepts either an Ecto schema module or a Postgrex connection tuple.
Parameters
source- Either:- Ecto schema module (e.g.,
MyApp.User) {:postgrex, conn, table_name}tuple{:postgrex, conn, table_name, schema}tuple
- Ecto schema module (e.g.,
Options
:include_associations- Include schema associations as joins (default: true):redact_fields- List of field names to mark as redacted:default_limit- Default limit for queries (default: 50):include_timestamps- Include timestamp fields in default selects (default: false)
Returns
A map containing:
:schema_module- The source module or table name:table_name- Database table name:primary_key- Primary key field name:fields- List of all available fields:field_types- Map of field names to their Selecto types:associations- Association metadata for joins:suggested_defaults- Recommended default configuration:redacted_fields- Fields that should be excluded from queries