Glific v0.3.1 Glific.Repo View Source
A repository that maps to an underlying data store, controlled by the Postgres adapter.
We add a few functions to make our life easier with a few helper functions that ecto does not provide.
Link to this section Summary
Functions
Callback implementation for Ecto.Repo.aggregate/3
.
Callback implementation for Ecto.Repo.aggregate/4
.
Callback implementation for Ecto.Repo.all/2
.
Callback implementation for Ecto.Repo.checkout/2
.
Callback implementation for Ecto.Repo.config/0
.
We use this function also in most list_OBJECT api's, where we process the the filter. Centralizing this code at the top level, to make things cleaner
Callback implementation for Ecto.Repo.default_options/1
.
Callback implementation for Ecto.Repo.delete/2
.
Callback implementation for Ecto.Repo.delete!/2
.
Callback implementation for Ecto.Repo.delete_all/2
.
In Join tables we rarely use the table id. We always know the object ids and hence more convenient to delete an entry via its object ids.
Callback implementation for Ecto.Repo.exists?/2
.
Glific version of get, which returns a tuple with an :ok | :error as the first element
Glific version of get_by, which returns a tuple with an :ok | :error as the first element
Add all the common filters here, rather than in each file
Callback implementation for Ecto.Repo.get/3
.
Callback implementation for Ecto.Repo.get!/3
.
Callback implementation for Ecto.Repo.get_by/3
.
Callback implementation for Ecto.Repo.get_by!/3
.
Callback implementation for Ecto.Repo.get_dynamic_repo/0
.
Callback implementation for Ecto.Repo.in_transaction?/0
.
Callback implementation for Ecto.Repo.insert/2
.
Callback implementation for Ecto.Repo.insert!/2
.
Callback implementation for Ecto.Repo.insert_all/3
.
Callback implementation for Ecto.Repo.insert_or_update/2
.
Callback implementation for Ecto.Repo.insert_or_update!/2
.
Get map of field (typically label) to ids for easier lookup for various system objects - language, tag
Extracts the limit offset field, and adds to query
We use this function in most list_OBJECT api's, where we process the opts and the filter. Centralizing this code at the top level, to make things cleaner
Callback implementation for Ecto.Repo.load/2
.
Callback implementation for Ecto.Repo.one/2
.
Callback implementation for Ecto.Repo.one!/2
.
A funtion which handles the order clause for a data type that has a 'name/body/label' in its schema (which is true for a fair number of Glific's data types)
An empty function for objects that ignore the opts
Callback implementation for Ecto.Repo.preload/3
.
Callback implementation for Ecto.Repo.prepare_query/3
.
Callback implementation for Ecto.Repo.put_dynamic_repo/1
.
A convenience function for SQL-based repositories that executes the given query.
A convenience function for SQL-based repositories that executes the given query.
Callback implementation for Ecto.Repo.rollback/1
.
Callback implementation for Ecto.Repo.start_link/1
.
Callback implementation for Ecto.Repo.stop/1
.
Callback implementation for Ecto.Repo.stream/2
.
A convenience function for SQL-based repositories that translates the given query to SQL.
Callback implementation for Ecto.Repo.transaction/2
.
Callback implementation for Ecto.Repo.update/2
.
Callback implementation for Ecto.Repo.update!/2
.
Callback implementation for Ecto.Repo.update_all/3
.
Link to this section Functions
Callback implementation for Ecto.Repo.aggregate/3
.
Callback implementation for Ecto.Repo.aggregate/4
.
Callback implementation for Ecto.Repo.all/2
.
Callback implementation for Ecto.Repo.checkout/2
.
Callback implementation for Ecto.Repo.config/0
.
Specs
count_filter( map(), atom(), (Ecto.Queryable.t(), %{optional(atom()) => any()} -> Ecto.Queryable.t()) ) :: integer()
We use this function also in most list_OBJECT api's, where we process the the filter. Centralizing this code at the top level, to make things cleaner
Callback implementation for Ecto.Repo.default_options/1
.
Callback implementation for Ecto.Repo.delete/2
.
Callback implementation for Ecto.Repo.delete!/2
.
Callback implementation for Ecto.Repo.delete_all/2
.
Specs
delete_relationships_by_ids( atom(), {{atom(), integer()}, {atom(), [integer()]}} ) :: {integer(), nil | [term()]}
In Join tables we rarely use the table id. We always know the object ids and hence more convenient to delete an entry via its object ids.
Callback implementation for Ecto.Repo.exists?/2
.
Specs
fetch(Ecto.Queryable.t(), term(), Keyword.t()) :: {:ok, Ecto.Schema.t()} | {:error, [String.t()]}
Glific version of get, which returns a tuple with an :ok | :error as the first element
Specs
fetch_by(Ecto.Queryable.t(), Keyword.t() | map(), Keyword.t()) :: {atom(), Ecto.Schema.t() | String.t()}
Glific version of get_by, which returns a tuple with an :ok | :error as the first element
Specs
filter_with(Ecto.Queryable.t(), %{optional(atom()) => any()}) :: Ecto.Queryable.t()
Add all the common filters here, rather than in each file
Callback implementation for Ecto.Repo.get/3
.
Callback implementation for Ecto.Repo.get!/3
.
Callback implementation for Ecto.Repo.get_by/3
.
Callback implementation for Ecto.Repo.get_by!/3
.
Callback implementation for Ecto.Repo.get_dynamic_repo/0
.
Callback implementation for Ecto.Repo.in_transaction?/0
.
Callback implementation for Ecto.Repo.insert/2
.
Callback implementation for Ecto.Repo.insert!/2
.
Callback implementation for Ecto.Repo.insert_all/3
.
Callback implementation for Ecto.Repo.insert_or_update/2
.
Callback implementation for Ecto.Repo.insert_or_update!/2
.
Specs
label_id_map(Ecto.Queryable.t(), [String.t()], non_neg_integer(), atom()) :: %{ required(String.t()) => integer() }
Get map of field (typically label) to ids for easier lookup for various system objects - language, tag
Specs
limit_offset(Ecto.Queryable.t(), map()) :: Ecto.Queryable.t()
Extracts the limit offset field, and adds to query
Specs
list_filter( map(), atom(), (Ecto.Queryable.t(), %{optional(atom()) => any()} -> Ecto.Queryable.t()), (Ecto.Queryable.t(), %{optional(atom()) => any()} -> Ecto.Queryable.t()) ) :: [any()]
We use this function in most list_OBJECT api's, where we process the opts and the filter. Centralizing this code at the top level, to make things cleaner
Callback implementation for Ecto.Repo.load/2
.
Callback implementation for Ecto.Repo.one/2
.
Callback implementation for Ecto.Repo.one!/2
.
Specs
opts_with_field(Ecto.Queryable.t(), map(), :name | :body | :label) :: Ecto.Queryable.t()
A funtion which handles the order clause for a data type that has a 'name/body/label' in its schema (which is true for a fair number of Glific's data types)
Specs
An empty function for objects that ignore the opts
Callback implementation for Ecto.Repo.preload/3
.
Callback implementation for Ecto.Repo.prepare_query/3
.
Callback implementation for Ecto.Repo.put_dynamic_repo/1
.
A convenience function for SQL-based repositories that executes the given query.
See Ecto.Adapters.SQL.query/4
for more information.
A convenience function for SQL-based repositories that executes the given query.
See Ecto.Adapters.SQL.query!/4
for more information.
Specs
Callback implementation for Ecto.Repo.rollback/1
.
Callback implementation for Ecto.Repo.start_link/1
.
Callback implementation for Ecto.Repo.stop/1
.
Callback implementation for Ecto.Repo.stream/2
.
A convenience function for SQL-based repositories that translates the given query to SQL.
See Ecto.Adapters.SQL.to_sql/3
for more information.
Callback implementation for Ecto.Repo.transaction/2
.
Callback implementation for Ecto.Repo.update/2
.
Callback implementation for Ecto.Repo.update!/2
.
Callback implementation for Ecto.Repo.update_all/3
.