anchor.diff:      Doc#doc{id=DocId, revs=Revs2};
   couch_doc_from_req(Req, DocId, Json) ->
       couch_doc_from_req(Req, DocId, couch_doc:from_json_obj(Json)).
  -
   
   % Useful for debugging
   % couch_doc_open(Db, DocId) ->
  
positive.code:             Doc
      end,
      DocId = Doc2#doc.id,
      case couch_httpd:qs_value(Req, "batch") of
      "ok" ->
          % async_batching
          spawn(fun() ->
                  case catch(couch_db:update_doc(Db, Doc2, [])) of
                  {ok, _} -> ok;
                  Error ->
                      ?LOG_INFO("Batch doc error (~s): ~p",[DocId, Error])
                  end
              end),
              
          send_json(Req, 202, [], {[
              {ok, true},
              {id, DocId}
          ]});
      _Normal ->
          % normal
          {ok, NewRev} = couch_db:update_doc(Db, Doc2, []),
          DocUrl = absolute_uri(
              Req, binary_to_list(<<"/",DbName/binary,"/", DocId/binary>>)),
          send_json(Req, 201, [{"Location", DocUrl}], {[
              {ok, true},
              {id, DocId},
              {rev, couch_doc:rev_to_str(NewRev)}
          ]})
      end;
  
  
  db_req(#httpd{path_parts=[_DbName]}=Req, _Db) ->
      send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");
  
negative.code:     {ok, DbInfo} = couch_db:get_db_info(Db),
      send_json(Req, {DbInfo});
  
  db_req(#httpd{method='POST',path_parts=[_DbName]}=Req, Db) ->
      couch_httpd:validate_ctype(Req, "application/json"),
      Doc = couch_doc:from_json_obj(couch_httpd:json_body(Req)),
      validate_attachment_names(Doc),
  