Provide geef_tree:count/1

This commit is contained in:
Carlos Martín Nieto
2013-07-24 23:55:54 +02:00
parent bed2e19ede
commit 52a6f72fef
5 changed files with 22 additions and 1 deletions

View File

@@ -101,6 +101,10 @@ tree_bypath(_TreeHandle, _Path) ->
tree_nth(_TreeHandle, _Nth) ->
?NIF_FN.
-spec tree_count(term) -> non_neg_integer().
tree_count(_Treehandle) ->
?NIF_FN.
-spec blob_size(term) -> {ok, integer()} | error.
blob_size(_ObjHandle) ->
nif_error(?LINE).

View File

@@ -4,7 +4,7 @@
-include_lib("eunit/include/eunit.hrl").
-endif.
-export([get/2, nth/2, lookup/2]).
-export([get/2, nth/2, count/1, lookup/2]).
-include("geef_records.hrl").
@@ -21,6 +21,10 @@ get(#geef_object{type=tree,handle=Handle}, Path) ->
nth(#geef_object{type=tree,handle=Handle}, Nth) ->
from_nif(geef_nif:tree_nth(Handle, Nth)).
-spec count(geef_object()) -> non_neg_integer().
count(#geef_object{type=tree,handle=Handle}) ->
geef_nif:tree_count(Handle).
-spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}.
lookup(Repo, Id) ->
geef_obj:lookup(Repo, Id, tree).