EctoQueryString v0.2.0 EctoQueryString.Reflection View Source

Provides some conveniences to work with Queries and Schemas

You can use this module to make sure the passed in fields are valid for the Query /Schema

Link to this section Summary

Functions

Return an associated schema

Get the :atom representation of a field if it exists in the passed in Ecto.Schema

Return an the foreign key of a schema's association

Check if an Ecto.Schema has the passed in association

Check if an Ecto.Schema has the passed in field

Return the primary key of a schema

Return all the primary keys of a schema

Return all the fields of the passed in Ecto.Schema

Find the source of an Ecto.Query

Link to this section Functions

Link to this function

assoc_schema(schema, assoc_name)

View Source
assoc_schema(Ecto.Schema, :binary) :: Ecto.Schema

Return an associated schema

Link to this function

field(schema, field_name)

View Source
field(Ecto.Schema, :binary) :: :atom | nil

Get the :atom representation of a field if it exists in the passed in Ecto.Schema

Link to this function

foreign_key(schema, assoc)

View Source
foreign_key(Ecto.Schema, :atom) :: :atom

Return an the foreign key of a schema's association

Link to this function

has_assoc?(schema, assoc_name)

View Source
has_assoc?(Ecto.Schema, :binary) :: :boolean

Check if an Ecto.Schema has the passed in association

Link to this function

has_field?(schema, field_name)

View Source
has_field?(Ecto.Schema, :binary) :: :boolean

Check if an Ecto.Schema has the passed in field

Link to this function

primary_key(schema)

View Source
primary_key(Ecto.Schema) :: :atom

Return the primary key of a schema

Link to this function

primary_keys(schema)

View Source
primary_keys(Ecto.Schema) :: :atom

Return all the primary keys of a schema

Link to this function

schema_fields(schema)

View Source
schema_fields(Ecto.Schema) :: [:binary]

Return all the fields of the passed in Ecto.Schema

The fields are returned as strings

Link to this function

source_schema(query)

View Source
source_schema(Ecto.Query) :: Ecto.Schema

Find the source of an Ecto.Query