AshBackpex.Adapter (ash_backpex v0.0.1)
View Source use Backpex.LiveResource,
adapter: InsiWeb.BackpexAshAdapter,
adapter_config: [
resource: User,
schema: User,
repo: Insi.Repo,
create_action: :create_with_plaintext_pwd,
create_changeset: &InsiWeb.BackpexAshAdapter.create_changeset/3,
update_changeset: &InsiWeb.BackpexAshAdapter.update_changeset/3,
load: &InsiWeb.BackpexAshAdapter.load/3
],
layout: {InsiWeb.Layouts, :admin}
You can specify a default create_action or update_action, which must refer to an action on the resource.
You must specify the create_changeset, update_changeset, and load functions because for some reason Backpex is not respecting the provided default Nimble values. Override them in your resource if necessary.
The Backpex.Adapter
to connect your Backpex.LiveResource
to an Ash.Resource
.
## adapter_config
:resource
(atom/0
) - Required. TheAsh.Resource
that will be used to perform CRUD operations.:schema
(atom/0
) - Required. TheAsh.Resource
for the resource.:repo
(atom/0
) - Required. TheEcto.Repo
that will be used to perform CRUD operations for the given schema.:create_action
(atom/0
) - The resource action to use when creating new items in the admin. Defaults to the primary create action.:read_action
(atom/0
) - The resource action to use when reading items in the admin. Defaults to the primary read action.:update_action
(atom/0
) - The resource action to use when updating items in the admin. Defaults to the primary update action.:destroy_action
(atom/0
) - The resource action to use when destroying items in the admin. Defaults to the primary destroy action.: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 theform
target that triggered the changeset call. Default tonil
if the call was not triggered by a form field. The default value is&AshBackpex.Adapter.create_changeset/3
.
:update_changeset
(function of arity 3) - Required. 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 theform
target that triggered the changeset call. Default tonil
if the call was not triggered by a form field. The default value is&AshBackpex.Adapter.update_changeset/3
.
:load
(function of arity 3) - Relationships, calculations and aggregates that Ash should load[comments: [:author]]
The default value is&AshBackpex.Adapter.load/3
.
Work in progress
The
Backpex.Adapters.Ash
is currently not usable! It can barely list and show items. We will work on this as we continue to implement theBackpex.Adapter
pattern throughout the codebase.
Summary
Functions
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.
Updates given item.
Updates given items.
Functions
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.
Returns nil
if no result was found.
Inserts given item.
Returns a list of items by given criteria.
Updates given item.
Updates given items.