Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 1.31 KB

README.md

File metadata and controls

31 lines (27 loc) · 1.31 KB

Lethink

An erlang driver for rethinkdb.

Status

Build Status

Use

> lethink:start().
> application:set_env(lethink, timeout, 60000).
> lethink:add_pool(my_db_pool, 5, [{database, "localhost"}, {port, 28015}]).
> lethink:query(my_db_pool, [{db_create, <<"superheroes">>}]).
> lethink:query(my_db_pool, [{db_list}]).
> lethink:query(my_db_pool, [{db_drop, <<"superheroes">>}]).
> lethink:query(my_db_pool, [{db, <<"superheroes">>}, {table_create, <<"marvel">>}]).
> lethink:query(my_db_pool, [{db, <<"superheroes">>},
                             {table_create, <<"marvel">>, [{primary_key, <<"name">>}]}]).
> lethink:query(my_db_pool, [{db, <<"superheroes">>}, {table_list}]).
> lethink:query(my_db_pool, [{db, <<"superheroes">>}, {table_drop, <<"marvel">>}]).
> lethink:use(my_db_pool, <<"superheroes">>).
> JsonProplist = [{[{<<"id">>, 5}, {<<"name">>, <<"batman">>}, {<<"rich">>, true}, {<<"cars">>, [1,2,3]}]},
                  {[{<<"id">>, 6}, {<<"name">>, <<"robin">>}, {<<"rich">>, false}, {<<"cars">>, null}]}].
> lethink:query(my_db_pool, [{table, <<"marvel">>},
                           {insert, JsonProplist}].
> lethink:query(my_db_pool, [{table, <<"marvel">>}, {get, 5}]).