PgRest.Select (PgRest v0.1.0)

Copy Markdown View Source

Applies parsed select AST to Ecto queries.

Supports:

  • Field selection on the root resource
  • Embed preloading with optional field selection
  • Embed filtering via preload queries
  • !inner joins for top-level filtering by associated data
  • Anti-joins via left join + is_nil check
  • Nested embeds (recursive preload structures)
  • Embed aliasing (renaming association keys in response)

Summary

Functions

apply_select(query, select_ast, resource_module, embed_filters, embed_options \\ %{})

@spec apply_select(Ecto.Queryable.t(), [map()] | nil, module(), map(), map()) ::
  Ecto.Queryable.t() | Ecto.Query.t()

Applies the parsed select AST to an Ecto query.

Splits the AST into root-level field selections and embed preloads, then applies each to the query using Ecto's select/3 and preload/3.