calcinator v1.0.0 Calcinator.Resources behaviour
A module that exposes Ecto schema structs
Summary
Types
Invoke name filter with value
ID that uniquely identifies the struct
Pagination information returned from the backing store
:associations- associations to load in thestruct:filters- filters on the result:page- the page used for pagination.nilimplies no pagination, not default pagination.:sorts- the directions to sort fields on the primary resource or its associations
A module that implements the Resources behaviour
Callbacks
Allows access to sandbox for testing
Changeset for creating a struct from the params
Changeset for updating struct with params
Deletes a single struct
Gets a single struct
Inserts params into a single new struct
Gets a list of structs
Returns
Applies updates in changeset
Updates struct
Types
Invoke name filter with value.
query_options() :: %{optional(:associations) => atom | [atom], optional(:filters) => [filter], optional(:page) => Resources.Page.t | nil, optional(:sorts) => Sorts.t}
:associations- associations to load in thestruct:filters- filters on the result:page- the page used for pagination.nilimplies no pagination, not default pagination.:sorts- the directions to sort fields on the primary resource or its associations
Callbacks
allow_sandbox_access(sandbox_access_token) :: :ok | {:already, :owner | :allowed} | :not_found
Allows access to sandbox for testing
Changeset for creating a struct from the params
Changeset for updating struct with params
Deletes a single struct
Returns
{:ok, struct}- the delete succeeded and the returned struct is the state before delete{:error, Ecto.Changeset.t}- errors while deleting thestruct.Ecto.Changeset.terrorscontains errors.
get(id, query_options) :: {:ok, struct} | {:error, :not_found} | {:error, :timeout} | {:error, reason :: term}
Gets a single struct
Returns
{:ok, struct}-idwas found.{:error, :not_found}-idwas not found.{:error, :timeout}- timeout occured while gettingidfrom backing store .{:error, reason}- an error occurred with the backing store forreasonthat is backing store specific.
insert(params, query_options) :: {:ok, struct} | {:error, Ecto.Changeset.t}
insert(Ecto.Changeset.t, query_options) :: {:ok, struct} | {:error, Ecto.Changeset.t}
Inserts params into a single new struct
Returns
{:ok, struct}- params were inserted intostruct{:error, Ecto.Changeset.t}- insert failed.Ecto.Changeset.terrorscontain errors.
list(query_options) :: {:ok, [struct], pagination | nil} | {:error, :timeout} | {:error, reason :: term}
Gets a list of structs.
Returns
{:ok, [resource], nil}- all resources matching query{:ok, [resource], pagination}- page of resources matching query{:error, :timeout}- timeout occured while getting resources from backing store .{:error, reason}- an error occurred with the backing store forreasonthat is backing store specific.
Returns
true- ifallow_sandbox_access/1should be called before any of the query methods are calledfalse- otherwise
update(Ecto.Changeset.t, query_options) :: {:ok, struct} | {:error, Ecto.Changeset.t}
Applies updates in changeset
Returns
{:ok, struct}- the update succeeded and the returnedstructcontains the updates{error, Ecto.Changeset.t}- errors while updatingstructwithparams.Ecto.Changeset.terrorscontains errors.
update(Ecto.Schema.t, params, query_options) :: {:ok, struct} | {:error, Ecto.Changeset.t} | {:error, :bad_gateway} | {:error, :not_found}
Updates struct
Returns
{:ok, struct}- the update succeeded and the returnedstructcontains the updates{:error, Ecto.Changeset.t}- errors while updatingstructwithparams.Ecto.Changeset.terrorscontains errors.{:error, :bad_gateway}- error in backing store that cannot be represented as another type of error{:error, :not_found}- the resource in the changeset was not found and so cannot be updated. This may mean that the resource was deleted withdelete/1after theget/2orlist/1returned.