dm-mnesia

A DataMapper adapter for Erlang’s Mnesia db

Requirements

You will need to install Rbridge.

Installation

sudo gem install dm-mnesia

Usage

Require the gem in your enviroment file

config.gem "dm-mnesia"

Initialize a connection using the adapter

connection = { :adapter => 'Mnesia',
                    :hostname => 'localhost',
                    :port => 9900,
                    :ids_table => 'NAME OF THE TABLE TO STORE UNIQUE IDS.',
                    :id_function=> 'NAME OF AN ERLANG FUNCTION TO CREATE UNIQUE IDS FOR YOUR RECORDS'}
    DataMapper.setup(:default, connection )

We used this example for the ids_table option </p>

Now you can define your models just like you would if you were using the DataMapper default adapters. All CRUD operations work the same as well.

Issues

When using a BinaryString type as a key for your model, you must set it to “:require=>false”, otherwise it won’t work When using a List type, you must assign the value to the column like so:

Model.mycolumn = ["value", "value"]

To Do List

In certain cases, the read command retrieves all record from Mnesia and filters, sorts them in ruby, more work needs to be done make this more efficient. This won’t be a problem if you are working with records around 2000.

Add missing Erlang types: Tuple, Atom.

Authors: Chad DePue ([email protected]), Manuel Gómez ([email protected])