The Backpex.Adapter to connect your Backpex.LiveResource to an Ecto.Schema.
adapter_config
:repo(atom/0) - Required. TheEcto.Repothat will be used to perform CRUD operations for the given schema.:schema(atom/0) - Required. TheEcto.Schemafor the resource.:update_changeset(function of arity 3) - Changeset to use when updating items. Additional metadata is passed as a keyword list via the third parameter::assigns- the assigns:target- the name of theformtarget that triggered the changeset call. Default tonilif the call was not triggered by a form field. The default value is&Backpex.Adapters.Ecto.default_changeset/3.
:create_changeset(function of arity 3) - Changeset to use when creating items. Additional metadata is passed as a keyword list via the third parameter::assigns- the assigns:target- the name of theformtarget that triggered the changeset call. Default tonilif the call was not triggered by a form field. The default value is&Backpex.Adapters.Ecto.default_changeset/3.
:item_query(function of arity 3) - The function that can be used to modify the ecto query. It will be used when resources are being fetched. This happens onindex,editandshowview. In most cases this function will be used to filter items onindexview based on certain criteria, but it may also be used to join other tables oneditorshowview.This function should accept the following parameters:
query-Ecto.Query.t()live_action-atom()assigns-map()
It should return an
Ecto.Queryable. It is recommended to build youritem_queryon top of the incoming query. Otherwise you will likely get binding errors.The default value is
&Backpex.Adapters.Ecto.default_item_query/3.
Work in progress
The Backpex.Adapters.Ecto is under heavy development and will change drastically in future updates.
Backpex started out as Ecto-only and we are working on decoupling things to support multiple data sources.
This is the first draft of moving all Ecto related functions into a dedicated Ecto adapter.
Summary
Functions
Applies validated filters to the query.
Applies a change to a given item.
Returns the number of items matching the given criteria.
Deletes multiple items.
Gets a database record with the given primary key value.
Inserts given item.
Returns a list of items by given criteria.
Returns the main database query for selecting a list of items by given criteria.
Gets name by schema. This is the last part of the module name as a lowercase atom.
Updates given item.
Updates given items.
Functions
Applies validated filters to the query.
Receives a map of validated filter values and the filter configurations keyword list. For each filter value, looks up the corresponding filter config and invokes the filter's query/4 callback with the already-validated and casted value.
Applies a change to a given item.
Returns the number of items matching the given criteria.
Deletes multiple items.
Gets a database record with the given primary key value.
Inserts given item.
Returns a list of items by given criteria.
Returns the main database query for selecting a list of items by given criteria.
TODO: Should be private.
Gets name by schema. This is the last part of the module name as a lowercase atom.
TODO: Make this private once all fields are using the adapter abstractions.
Updates given item.
Updates given items.