anchor.diff:  % internal
   
   infer_type_from_id(Id) when is_list(Id) ->
  -    [Type, TableId] = string:tokens(Id, "-"),
  -    {list_to_atom(Type), type_to_table_name(Type), list_to_integer(TableId)}.
  +    [Type, BossId] = string:tokens(Id, "-"),
  +    {list_to_atom(Type), type_to_collection(Type), boss_to_mongo_id(Id)}.
   
   type_to_table_name(Type) when is_atom(Type) ->
       type_to_table_name(atom_to_list(Type));
  
positive.code:     "TRUE";
  pack_value(false) ->
      "FALSE".
  
negative.code:     end.
  
  delete(Conn, Id) when is_list(Id) ->
      ?LOG("ID", Id),
      {_Type, Collection, MongoId} = infer_type_from_id(Id),
      
      Res = execute(Conn, fun() ->
                  mongo:delete(Collection, {'_id', MongoId})
          end),
      ?LOG("Res", Res),
      case Res of
          {ok, ok} -> ok;
          {failure, Reason} -> {error, Reason};
          {connection_failure, Reason} -> {error, Reason}
      end.
  
  proplist_to_tuple(PropList) ->
      ListOfLists = [[K,V]||{K,V} <- PropList],
      list_to_tuple(lists:foldl(
              fun([K, V], Acc) ->
                      [K,V|Acc] 
              end, [], ListOfLists)).
  
  type_to_collection(Type) ->
      list_to_atom(type_to_table_name(Type)).
  
  save_record(Conn, Record) when is_tuple(Record) ->
      Type = element(1, Record),
      Collection = type_to_collection(Type),
      Attributes = case Record:id() of
          id ->
              proplist_to_tuple(proplists:delete(id, Record:attributes()));
          DefinedId when is_list(DefinedId) ->
              io:format(">>>> ~p, ~p~n", [Type, DefinedId]),
              PropList = lists:map(fun({K,V}) ->
                              case K of 
                                  id -> {'_id', boss_to_mongo_id(DefinedId)};
                                  _ -> {K, V}
                              end
                      end, Record:attributes()),
              proplist_to_tuple(PropList)
      end,
      Res = execute(Conn, fun() -> 
                  mongo:save(Collection, Attributes)
          end),
      case Res of
          {ok, ok} -> {ok, Record};
          {ok, Id} -> 
              {ok, Record:id(mongo_to_boss_id(Type, Id))};
          {failure, Reason} -> {error, Reason};
          {connection_failure, Reason} -> {error, Reason}
      end.
  