DBMS

Overview

During the build of your application you will notice there is a very narrow usage of the most common database operations:

The e_db module provides a convenient API to all those operations.

Supported DBMS

Currently only Mnesia and CouchDB DBMS are supported. Moreover, CouchDB support is in incubation phase, so it is not recommended you use it in production systems. To set the desired DBMS you specify its name in the project.conf file:

{dbms, DBMS}.

where DBMS is either mnesia for Mnesia support or couchdb for CouchDB.

After setting this option, the access to the selected DBMS is completely transparent when you are using e_db module.

e_db module

The e_db module is a transparent API to the DBMS laying a foundation for the system. It allows you to run the following operations on the database:

Example

The following examples demonstrate the basic use cases of the e_db module:

%% creating new item
ID = e_db:get_next_id(blog_post),
Post = blog_post:create_post(ID),
e_db:write(blog_post, Post),
...
%% reading all the items
Posts = e_db:read(blog_post),
...
%% reading the particular item
Post = e_db:read(blog_post, 10),
...
%% updating the existing item
Post = e_db:read(blog_post, 3),
NewPost = blog_post:update_post(Post),
e_db:update(blog_post, NewPost),
...
%% removing the item
Post = e_db:read(blog_post, 5),
e_db:delete(blog_post, Post),
...
%% getting the domain size
Size = e_db:size(blog_post),
...

DBMS (last edited 2011-03-20 10:01:41 by BruceFitzsimons)