Browse files

fix count

  • Loading branch information...
1 parent 086b305 commit afffef77ae1e48b5eb40a9669f0ac7f56387a4b6 @SergejJurecko committed Jan 7, 2016
Showing with 9 additions and 4 deletions.
  1. +7 −2 src/mongoapi.erl
  2. +2 −2 src/mongodb.erl
View
9 src/mongoapi.erl
@@ -404,8 +404,13 @@ count(ColIn, Query,{?MODULE,[Pool,DB]}) ->
Cmd = [{plaintext, <<"count">>, Col}, {plaintext, <<"ns">>, DB}]
end,
case mongodb:exec_cmd(Pool,DB, Cmd) of
- [{<<"n">>, Val}|_] ->
- round(Val);
+ [_|_] = Obj ->
+ case proplists:get_value(<<"n">>,Obj) of
+ undefined ->
+ false;
+ Val ->
+ round(Val)
+ end;
_ ->
false
end.
View
4 src/mongodb.erl
@@ -535,7 +535,7 @@ init([]) ->
{ok, HN} = inet:gethostname(),
<<HashedHN:3/binary,_/binary>> = erlang:md5(HN),
process_flag(trap_exit, true),
- {A1,A2,A3} = now(),
+ {A1,A2,A3} = os:timestamp(),
random:seed(A1, A2, A3),
{ok, #mngd{indexes = ets:new(mongoIndexes, [set, private]), hashed_hostn = HashedHN}}.
@@ -770,7 +770,7 @@ connection(#con{} = P,Index,Buf) ->
{stop} ->
true;
{start, Pool, Source, Type, IP, Port} ->
- {A1,A2,A3} = now(),
+ {A1,A2,A3} = os:timestamp(),
random:seed(A1, A2, A3),
{ok, Sock} = gen_tcp:connect(IP, Port, [binary, {packet, 0}, {active, once}, {keepalive, true}]),
case Type of

0 comments on commit afffef7

Please sign in to comment.