# Execs

[![Build Status](](
[![ Version](](
[![Inline docs](](

Elixir Entity Component System. Abstracts away the mechanisms used to store, lookup, and retrieve data in an Entity-Component System.

Note that this application only provides the mechanisms for working with data and expects the consuming application to provide the "System" part of the equation.

**WARNING**: This software is new and has been minimally tested.

## Including as Dependency

defp deps do
  [{:execs, "~> 0.4.0"}]

## Managing database

There are six mix tasks provided as hooks for managing the lifecycle of the database:
* execs.schema.create
* execs.schema.delete
* execs.tables.create
* execs.tables.drop 
* execs.setup
* execs.teardown

Which hooks to run will depend on the client being used. In the case of the
Mnesia (default) client, a schema must first be created and then the tables can be created.

The setup/teardown tasks run both the schema and table creation and destruction tasks respectively.

## Configuration
There are a few possible configuration values, with sensible defaults, for this package:

Key                  | Default Value         | Affect
:--------------------| :---------------------| :--------------------------------
ai_table_name        | ai_table              | Name of the autoincrement table
data_table_name      | data_table            | Name of the data table
db_client            | Execs.DbClient.Mnesia | Client module performs db interactions

## Examples
These are some basic examples. See documentation and tests for more thorough coverage.
# Write a value to a single key, of a single component, of a single entity 
Execs.transaction(fn ->
  Execs.write(id, :foo, :bar, :foobar)

# Write a value to a single key, of multiple components, of a single entity 
Execs.transaction(fn ->
  Execs.write(id, [:foo, :bar], :bar, :foobar)

# Write a value to multiple keys, of multiple components, of multiple entities 
Execs.transaction(fn ->
  Execs.write([id, id2], [:foo, :bar], [:foo, :bar], :foobar)

# Write a series of key/value pairs to a single component of a single entity
Execs.transaction(fn ->
  |> Execs.write(:foo, :bar, :foobar)
  |> Execs.write(:foo, :bar, :foobar)
  |> Execs.write(:foo, :foo, :foobar)
  |> Execs.write(:foo, :foobar, :foobar)

# Read an entire entity from database 
Execs.transaction(fn ->

# Read the value of a single key from database 
Execs.transaction(fn ->, :foo, :bar)