class Mongoid::Document::OrmAdapter

def conditions_to_fields(conditions)

converts and documents to ids
def conditions_to_fields(conditions)
  conditions.inject({}) do |fields, (key, value)|
    if value.is_a?(Mongoid::Document) && klass.fields.keys.include?("#{key}_id")
      fields.merge("#{key}_id" => value.id)
    elsif key.to_s == 'id'
      fields.merge('_id' => value)
    else
      fields.merge(key => value)
    end
  end
end