View Source EctoQueryString.Reflection (EctoQueryString v0.2.2)

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
@spec assoc_schema(Ecto.Schema, binary()) :: Ecto.Schema

Return an associated schema

Link to this function

field(schema, field_name)

View Source
@spec field(Ecto.Schema, binary()) :: {atom(), atom()} | {nil, :no_field}

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
@spec 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
@spec 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
@spec has_field?(Ecto.Schema, binary()) :: boolean()

Check if an Ecto.Schema has the passed in field

@spec primary_key(Ecto.Schema) :: atom()

Return the primary key of a schema

@spec primary_keys(Ecto.Schema) :: atom()

Return all the primary keys of a schema

@spec schema_fields(Ecto.Schema) :: [:binary]

Return all the fields of the passed in Ecto.Schema

The fields are returned as strings

@spec source_schema(Ecto.Query) :: Ecto.Schema

Find the source of an Ecto.Query