anchor.diff:          ViewName::string()}, Options::view_options()) 
       -> integer() | {error, term()}.
   %% @doc count number of doc in a view (or all docs)
  -count(#db{server=Server, options=IbrowseOpts}=Db, 'all_docs', 
  -        Options) ->
  -    case parse_view_options(Options) of
  -        {error, _} = Error ->
  -            Error;
  -        Args ->
  -            Url = couchbeam:make_url(Server, [couchbeam:db_url(Db),
  -                "/_all_docs"], Args#view_query_args.options),
  -            do_count(Args, Url, IbrowseOpts)
  -    end;
  -count(#db{server=Server, options=IbrowseOpts}=Db, {DesignName,
  -        ViewName}, Options)->
  -    case parse_view_options(Options) of
  -        {error, _} = Error ->
  -            Error;
  -        Args ->
  -            Url = couchbeam:make_url(Server, [couchbeam:db_url(Db),
  -                "/_design/", DesignName, "/_view/", ViewName],
  -                Args#view_query_args.options),
  -            do_count(Args, Url, IbrowseOpts)
  -    end;
  -count(_, _, _) ->
  -    {error, invalid_view_name}.
  +count(#db{options=IbrowseOpts}=Db, ViewName, Options)->
  +    make_view(Db, ViewName, Options, fun(Args, Url) ->
  +        Result = case Args#view_query_args.method of
  +            get ->
  +                couchbeam_httpc:request(get, Url, ["200"], IbrowseOpts);
  +            post ->
  +                Body = ejson:encode({[{<<"keys">>, Args#view_query_args.keys}]}),
  +                Headers = [{"Content-Type", "application/json"}],
  +                couchbeam_httpc:request_stream(post, Url, ["200"],
  +                    IbrowseOpts, Headers, Body)
  +        end,
  +        case Result of
  +            {ok, _, _, RespBody} ->
  +                {Props} = ejson:decode(RespBody),
  +                case proplists:get_value("limit",
  +                        Args#view_query_args.options, 0) of
  +                0 ->
  +                    proplists:get_value(<<"total_rows">>, Props);
  +                _ ->
  +                    Rows = proplists:get_value(<<"rows">>, Props),
  +                    length(Rows)
  +                end;
  +            Error ->
  +                Error
  +        end
  +    end).
   
   -spec first(Db::db()) -> {ok, Row::ejson_object()} | {error, term()}.
   %% @equiv first(Db, 'all_docs', [])
  
positive.code:          count/1, count/2, count/3,
           first/1, first/2, first/3,
           all/1, all/2,
           view_loop/2, parse_view_options/1]).
  
  -spec all(Db::db()) -> {ok, Rows::list(ejson_object())} | {error, term()}.
  
negative.code: 
  %% @private
  
  make_view(#db{server=Server}=Db, ViewName, Options, Fun) ->
      case parse_view_options(Options) of
          {error, _} = Error ->
              Error;
          Args ->
              case ViewName of
                  'all_docs' ->
                      Url = couchbeam:make_url(Server, [couchbeam:db_url(Db), 
                              "/_all_docs"],
                              Args#view_query_args.options),
                      Fun(Args, Url);
                  {DName, VName} ->
                      Url = couchbeam:make_url(Server, [couchbeam:db_url(Db), 
                              "/_design/", DName, "/_view/", VName],
                              Args#view_query_args.options),
                      Fun(Args, Url);
                  _ ->
                      {error, invalid_view_name}
              end
      end.
      
  collect_view_first(Ref, Pid) ->
      receive
          {row, Ref, done} ->
  