anchor.diff:           store_item/5,
            about_me/1]).
   
  --spec put_region(binary()) -> {ok, key()}.
  +-spec put_region(binary()) -> {ok, key()} | {error, reason()}.
   put_region(RegionName) ->
       %% Each region has its own grouping, determined by their region name (unique)
       ChosenPartition = log_utilities:get_key_partition(RegionName),
  
positive.code:             %% If the username is not unique, abort the transaction
              {error, non_unique_username}
      end,
      {ok, []} = pvc:commit_transaction(TxId),
  
      Result.
  
  -spec browse_categories() -> {ok, list()}.
  browse_categories() ->
      CategoryNameIndex = rubis_utils: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),
      {ok, []} = pvc:commit_transaction(TxId),
      Result.
  
  -spec search_items_by_category(key()) -> {ok, list()}.
  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),
      Res = pvc:read_keys(ItemKeys, TxId),
      {ok, []} = pvc:commit_transaction(TxId),
      Res.
  
  -spec browse_regions() -> {ok, list()}.
  browse_regions() ->
      RegionNameIndex = rubis_utils: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),
      {ok, []} = pvc:commit_transaction(TxId),
      Result.
  
  -spec search_items_by_region(key(), key()) -> {ok, list()}.
  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 = rubis_utils:gen_index_name(RegionName, users_region),
      {ok, UsersInRegion} = pvc_indices:read_index(UserRegionIndex, TxId),
      MatchingItems = lists:flatmap(fun(UserKey) ->
          SellerGroup = rubis_utils:get_grouping(UserKey),
          SellerIndex = rubis_utils: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),
  
negative.code:     CommentId = rubis_keygen_vnode:next_id(SelfPartition, comments),
      CommentKey = ?ru:gen_key(SelfGrouping, comments, CommentId),
      CommentObj = #comment{from = FromId,
                            to = ToId,
                            on_item = OnItemId,
                            rating = Rating,
                            body = Body},
  
      {ok, TxId} = pvc:start_transaction(),
  
  