anchor.diff:  %%--------------------------------------------------------------------
   -spec gateway_loop(State :: #{atom() => term()}) -> no_return().
   gateway_loop(#{port_fd := PortFD, id := {_, N} = ID, db_hostname := Hostname, db_port := Port, gw_port := GWPort,
  -    start_time := ST, parent := Parent, last_ping_time := LPT, bucket := Bucket} = State) ->
  +    start_time := ST, parent := Parent, last_ping_time := LPT, bucket := Bucket, doc_batch_ts := DocBatchTS} = State) ->
   
       %% Update state
       Gateways = datastore_worker:state_get(db_gateways),
  
positive.code: %% Returns server handle used by couchbeam library to connect to couchdb-based DB.
  %% @end
  %%--------------------------------------------------------------------
  -spec get_server(binary()) -> {ok, {pid, term()}} | {error, term()}.
  get_server(Bucket) ->
      get_server(datastore_worker:state_get(db_gateways), Bucket).
  
  
negative.code: save_doc(ModelConfig, #document{rev = undefined} = Doc) ->
      create(ModelConfig, Doc);
  save_doc(#model_config{bucket = Bucket} = ModelConfig, ToSave = #document{key = Key, rev = Rev, value = Value}) ->
      Doc = make_raw_doc(ModelConfig, ToSave),
  
      {ok, {Pid, _}} = get_server(Bucket),
      Ref = make_ref(),
      Pid ! {{self(), Ref}, Doc},
      receive
          {Ref, Response} ->
              Response
      after
          timer:seconds(10) ->
              {error, loop_timeout}
      end.
  
  %%save_doc_sync(ModelConfig, ToSave = #document{key = Key, rev = Rev, value = Value}) ->
  %%    Doc = make_raw_doc(ModelConfig, ToSave),
  %%    case db_run(select_bucket(ModelConfig, ToSave), couchbeam, save_doc, [Doc, ?DEFAULT_DB_REQUEST_TIMEOUT_OPT], 3) of
  %%        {ok, {SaveReport}} ->
  %%            case verify_ans(SaveReport) of
  %%                true ->
  %%                    {ok, Key};
  %%                _ ->
  %%                    {error, db_internal_error}
  %%            end;
  %%        {error, conflict} ->
  %%            {error, already_exists};
  %%        {error, Reason} ->
  %%            {error, Reason}
  %%    end.
  
  make_raw_doc(#model_config{bucket = Bucket} = ModelConfig, #document{key = Key, rev = Rev, value = Value}) ->
      ok = assert_value_size(Value, ModelConfig, Key),
  
      {Props} = to_json_term(Value),
      {[{<<"_rev">>, Rev}, {<<"_id">>, to_driver_key(Bucket, Key)} | Props]}.
  
  %%--------------------------------------------------------------------
  %% @doc
  