anchor.diff:              end
           end, SoldByUser)
       end, UsersInRegion),
  -    {ok, []} = pvc:commit_transaction(TxId),
  -    MatchingItems.
  -
  --spec view_item(key()) -> {ok, #view_item{}}.
  +    Commit = pvc:commit_transaction(TxId),
  +
  +    case Commit of
  +        ?committed ->
  +            MatchingItems;
  +        {error, Reason} ->
  +            {error, Reason}
  +    end.
  +
  +-spec view_item(key()) -> {ok, #view_item{}} | {error, reason()}.
   view_item(ItemId) ->
       {ok, TxId} = pvc:start_transaction(),
       {ok, [Item]} = pvc:read_keys(ItemId, TxId),
  
positive.code: -define(ru, rubis_utils).
  -define(default_group, <<"global_index">>).
  
  -type key() :: term().
  -type reason() :: atom().
  
  
negative.code:             %% If the username is not unique, abort the transaction
              {error, non_unique_username}
      end,
      Commit = pvc:commit_transaction(TxId),
  
      case Commit of
          ?committed ->
              Result;
          {error, Reason} ->
              {error, Reason}
      end.
  
  -spec browse_categories() -> {ok, list()} | {error, reason()}.
  browse_categories() ->
      CategoryNameIndex = ?ru:gen_index_name(?default_group, categories_name),
      {ok, TxId} = pvc:start_transaction(),
      {ok, CategoryKeys} = pvc_indices:read_index(CategoryNameIndex, TxId),
      Result = pvc:read_keys(CategoryKeys, TxId),
      Commit = pvc:commit_transaction(TxId),
  
      case Commit of
          ?committed ->
              Result;
          {error, Reason} ->
              {error, Reason}
      end.
  
  -spec search_items_by_category(key()) -> {ok, list()} | {error, reason()}.
  search_items_by_category(CategoryId) ->
      CategoryGrouping = ?ru:get_grouping(CategoryId),
      CategoryIndex = ?ru:gen_index_name(CategoryGrouping, items_category_id),
      {ok, TxId} = pvc:start_transaction(),
      {ok, ItemKeys} = pvc_indices:read_index(CategoryIndex, CategoryId, TxId),
      Result = pvc:read_keys(ItemKeys, TxId),
      {ok, []} = pvc:commit_transaction(TxId),
      Commit = pvc:commit_transaction(TxId),
  
      case Commit of
          ?committed ->
              Result;
          {error, Reason} ->
              {error, Reason}
      end.
  
  -spec browse_regions() -> {ok, list()} | {error, reason()}.
  browse_regions() ->
      RegionNameIndex = ?ru:gen_index_name(?default_group, regions_name),
      {ok, TxId} = pvc:start_transaction(),
      {ok, RegionKeys} = pvc_indices:read_index(RegionNameIndex, TxId),
      Result = pvc:read_keys(RegionKeys, TxId),
      Commit = pvc:commit_transaction(TxId),
  
      case Commit of
          ?committed ->
              Result;
          {error, Reason} ->
              {error, Reason}
      end.
  
  -spec search_items_by_region(key(), key()) -> {ok, list()} | {error, reason()}.
  search_items_by_region(CategoryId, RegionId) ->
      %% Get all items in category CategoryId, such that their sellers
      %% are part of the given region
      {ok, TxId} = pvc:start_transaction(),
      {ok, [RegionName]} = pvc:read_keys(RegionId, TxId),
      UserRegionIndex = ?ru:gen_index_name(RegionName, users_region),
      {ok, UsersInRegion} = pvc_indices:read_index(UserRegionIndex, TxId),
      MatchingItems = lists:flatmap(fun(UserKey) ->
          SellerGroup = ?ru:get_grouping(UserKey),
          SellerIndex = ?ru:gen_index_name(SellerGroup, items_seller_id),
          {ok, SoldByUser} = pvc_indices:read_index(SellerIndex, UserKey, TxId),
          lists:filtermap(fun(ItemKey) ->
              {ok, [Item]} = pvc:read_keys(ItemKey, TxId),
  