anchor.diff:      end.
   
   update_doc(Db, Doc, Options) ->
  -    case is_couchbase_db(Db#db.name) of
  -        false -> couch_db:update_doc(Db, Doc, Options)
  -    end.
  +    update_doc(Db, Doc, Options, interactive_edit).
  +
  +update_doc(#db{filepath = undefined} = Db, #doc{id = <<"_design/",_/binary>>} = Doc, Options, UpdateType) ->
  +    with_subdb(Db, <<"master">>,
  +               fun (RealDb) ->
  +                       couch_db:update_doc(RealDb, Doc, Options, UpdateType)
  +               end);
  +
  +update_doc(#db{filepath = undefined} = Db, Doc, Options, UpdateType) ->
  +    %% TODO: route to right vbucket, node and into memcached
  +    with_subdb(Db, 0,
  +               fun (RealDb) ->
  +                       couch_db:update_doc(RealDb, Doc, Options, UpdateType)
  +               end);
   
   update_doc(Db, Doc, Options, UpdateType) ->
  -    case is_couchbase_db(Db#db.name) of
  -        false -> couch_db:update_doc(Db, Doc, Options, UpdateType)
  -    end.
  -
  +    couch_db:update_doc(Db, Doc, Options, UpdateType).
  +
  +update_docs(Db, Docs, Options) ->
  +    update_docs(Db, Docs, Options, interactive_edit).
  +
  +update_docs(#db{filepath = undefined} = Db, Docs, Options, Type) ->
  +    {DesignDocs, [] = NormalDocs} =
  +        lists:partition(fun (#doc{id = <<"_design/", _/binary>>}) -> true;
  +                            (_) -> false
  +                        end, Docs),
  +    case update_design_docs(Db, DesignDocs, Options, Type) of
  +        {ok, DDocResults} ->
  +            %% TODO: work out error handling here
  +            {ok, NormalResults} = update_normal_docs(Db, NormalDocs,
  +                                                     Options, Type),
  +            %% TODO: Looks like we need to reorder results here
  +            {ok, NormalResults ++ DDocResults};
  +        Error ->
  +            %% TODO: work out error handling here
  +            Error
  +    end;
  +update_docs(Db, Docs, Options, Type) ->
  +    couch_db:update_docs(Db, Docs, Options, Type).
  +
  +
  +update_design_docs(#db{filepath = undefined} = Db, Docs, Options, Type) ->
  +    with_subdb(Db, <<"master">>,
  +               fun (RealDb) ->
  +                       couch_db:update_docs(RealDb, Docs, Options, Type)
  +               end).
  +
  +update_normal_docs(_Db, [], _Options, _Type) ->
  +    {ok, []};
  +update_normal_docs(Db, Docs, Options, Type) ->
  +    exit(not_implemented(update_normal_docs, [Db, Docs, Options, Type])).
  +
  +-spec ensure_full_commit(any(), integer()) -> {ok, binary()}.
  +ensure_full_commit(#db{filepath = undefined} = _Db, _RequiredSeq) ->
  +    {ok, <<"0">>};
   ensure_full_commit(Db, RequiredSeq) ->
       UpdateSeq = couch_db:get_update_seq(Db),
       CommittedSeq = couch_db:get_committed_update_seq(Db),
  
positive.code:             end
      end.
  
  check_is_admin(_Db) ->
      ok.
  
  
  
  handle_changes(ChangesArgs, Req, Db) ->
      couch_changes:handle_changes(ChangesArgs, Req, Db).
  
  start_view_compact(DbName, GroupId) ->
      exit(not_implemented(start_view_compact, [DbName, GroupId])).
  
  start_db_compact(Db) ->
      exit(not_implemented(start_db_compact, [Db])).
  
  cleanup_view_index_files(Db) ->
      couch_view:cleanup_index_files(Db).
  
  get_group_info(Db, DesignId) ->
      with_vbucket_db(Db, 0,
                      fun (RealDb) ->
                              couch_view:get_group_info(RealDb, DesignId)
                      end).
  
  create_db(DbName, UserCtx) ->
      exit(not_implemented(create_db, [DbName, UserCtx])).
  
  delete_db(DbName, UserCtx) ->
      exit(not_implemented(delete_db, [DbName, UserCtx])).
  
  update_docs(Db, Docs, Options) ->
      case is_couchbase_db(Db#db.name) of
          false -> couch_db:update_docs(Db, Docs, Options)
      end.
  
  update_docs(Db, Docs, Options, Type) ->
      case is_couchbase_db(Db#db.name) of
          false -> couch_db:update_docs(Db, Docs, Options, Type)
      end.
  
  purge_docs(Db, IdsRevs) ->
      %% couch_db:purge_docs(Db, IdsRevs).
  
negative.code: 
  -spec all_databases() -> {ok, [binary()]}.
  all_databases() ->
      {ok, DBs} = couch_server:all_databases(),
      {ok, DBs ++ [?l2b(Name) || Name <- ns_bucket:get_bucket_names(membase)]}.
  
  task_status_all() ->
      %% TODO: why ?
      couch_task_status:all().
  
  restart_core_server() ->
  