Any API usage docs? #22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi. I can't find api docs. Are there any?
How should I write and read data from erlang? Maybe there is some simple usage example?
👍
Here is my little 'write and read data from erlang' sheet :
{ok, Tree} = hanoidb:open("mydb.hanoidb").
ok = hanoidb:put(Tree, <<"key1">>, <<"val1">>).
ok = hanoidb:put(Tree, <<"key2">>, <<"val2">>).
{ok,<<"val1">>} = hanoidb:get(Tree, <<"key1">>).
{ok,<<"val2">>} = hanoidb:get(Tree, <<"key2">>).
ok = hanoidb:close(Tree).
After put/get, here is delete (before close obviously) :
ok = hanoidb:delete(Tree, <<"BOO">>),
not_found = hanoidb:get(Tree, <<"BOO">>)
There si also key expiry:
ok = hanoidb:put(Tree, <<"foo">>, <<"bar">>, 2), % 2 sec
{ok, <<"bar">>} = hanoidb:get(Tree, <<"foo">>),
ok = timer:sleep(3000), % 3000 ms
not_found = hanoidb:get(Tree, <<"foo">>)
And the powerfull fold(DB, Fun, Acc)
see also fold_range in the source.
Hope it helps
Have fun