ecto_cassandra v1.0.0-rc.3 EctoCassandra.Adapter View Source
Ecto Adapter for Apache Cassandra.
It uses cassandra
for communicating to the database
Link to this section Summary
Functions
Called to autogenerate a value for id/embed_id/binary_id
Returns the dumpers for a given type
Returns the loaders for a given type
Commands invoked to prepare a query for all
, update_all
and delete_all
Link to this section Functions
Called to autogenerate a value for id/embed_id/binary_id.
Returns the autogenerated value, or nil if it must be autogenerated inside the storage or raise if not supported.
Callback implementation for Ecto.Adapter.autogenerate/1
.
Returns the dumpers for a given type.
It receives the primitive type and the Ecto type (which may be primitive as well). It returns a list of dumpers with the given type usually at the beginning.
This allows developers to properly translate values coming from the Ecto into adapter ones. For example, if the database does not support booleans but instead returns 0 and 1 for them, you could add:
def dumpers(:boolean, type), do: [type, &bool_encode/1]
def dumpers(_primitive, type), do: [type]
defp bool_encode(false), do: {:ok, 0}
defp bool_encode(true), do: {:ok, 1}
All adapters are required to implement a clause or :binary_id types, since they are adapter specific. If your adapter does not provide binary ids, you may simply use Ecto.UUID:
def dumpers(:binary_id, type), do: [type, Ecto.UUID]
def dumpers(_primitive, type), do: [type]
Callback implementation for Ecto.Adapter.dumpers/2
.
Returns the loaders for a given type.
It receives the primitive type and the Ecto type (which may be primitive as well). It returns a list of loaders with the given type usually at the end.
This allows developers to properly translate values coming from the adapters into Ecto ones. For example, if the database does not support booleans but instead returns 0 and 1 for them, you could add:
def loaders(:boolean, type), do: [&bool_decode/1, type]
def loaders(_primitive, type), do: [type]
defp bool_decode(0), do: {:ok, false}
defp bool_decode(1), do: {:ok, true}
All adapters are required to implement a clause for :binary_id
types,
since they are adapter specific. If your adapter does not provide binary
ids, you may simply use Ecto.UUID:
def loaders(:binary_id, type), do: [Ecto.UUID, type]
def loaders(_primitive, type), do: [type]
Callback implementation for Ecto.Adapter.loaders/2
.
Commands invoked to prepare a query for all
, update_all
and delete_all
.
The returned result is given to execute/6
.
Callback implementation for Ecto.Adapter.prepare/2
.