Noizu.Entity.Store.Amnesia.EntityProtocol protocol (NoizuLabs Entities v0.2.1)

Protocol used to save/load entities from store. Leverage Entity.FieldProtocol to pack/unpack individual fields.

Summary

Types

Context Record

An Entity That Implements the Entity Protocol

Options Keyword List

An Amnesia Record

Persistence Settings

t()

All the types that implement this protocol.

Field Handler

Types

context()

@type context() :: any()

Context Record

entity()

@type entity() :: any()

An Entity That Implements the Entity Protocol

options()

@type options() :: nil | list()

Options Keyword List

record()

@type record() :: any()

An Amnesia Record

settings()

Persistence Settings

t()

@type t() :: term()

All the types that implement this protocol.

type()

@type type() :: any()

Field Handler

Functions

as_entity(entity, record, settings, context, options)

@spec as_entity(entity(), record(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

Transform record to entity

as_record(entity, settings, context, options)

@spec as_record(entity(), settings(), context(), options()) ::
  {:ok, record()} | {:error, any()}

Transform to expected entity record format.

delete_record(entity, settings, context, options)

@spec delete_record(entity(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

Delete record entity

fetch_as_entity(entity, settings, context, options)

@spec fetch_as_entity(entity(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

Transform record to entity

from_record(record, settings, context, options)

@spec from_record(record(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

as_entity helper convert record to entity - fetch

merge_from_record(entity, record, settings, context, options)

@spec merge_from_record(entity(), record(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

as_entity helper convert record to entity

persist(entity, type, settings, context, options)

@spec persist(entity(), type(), settings(), context(), options()) ::
  {:ok, entity()} | {:error, any()}

Save entity to store.