anchor.diff:          true ->
               Collection = type_to_collection(Type),
               Res = execute(Conn, fun() ->
  -                    SortOrder1 = case SortOrder of 
  -                        str_ascending -> 1;
  -                        num_ascending -> 1;
  -                        str_descending -> -1;
  -                        num_descending -> -1
  -                    end,
                       Selector = build_conditions(Conditions, 
  -                                                {Sort, SortOrder1}),
  +                                                {Sort, pack_sort_order(SortOrder)}),
                       mongo:find(Collection, Selector, [],
                                  Skip, Max) 
                   end),
  
positive.code:     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.
  
negative.code: 
  pop(_Conn, _Depth) -> ok.
  
  
  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% Internal functions
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  %%
  %% Query generation
  %%
  
  build_conditions(Conditions) ->
      proplist_to_tuple(build_conditions1(Conditions, [])).
  