mongomapper를 통해 쿼리하는 mongo가있는 레일 앱이 있습니다.mongomapper (및 plucky)와 함께 "in"절 연결
내 응용 프로그램의 다른 부분에서 두 개의 $in
절을 쿼리에 추가하고 싶습니다. 예 :
def where_clause1
where(app_ids: {'$in' => [5, 42, 23]})
end
def where_clause2
where(app_ids: {'$in' => [44, 5, 87]})
end
두 조항을 서로 배타적으로 사용하고 싶습니다.
는하지만 내가 할 경우 :
$> User.where_clause1
=> #<MongoMapper::Plugins::Querying::DecoratedPluckyQuery
app_ids: {"$in"=>[5, 42, 23]}, transformer: ...>
$> User.where_clause2
=> #<MongoMapper::Plugins::Querying::DecoratedPluckyQuery
app_ids: {"$in"=>[44, 5, 87]}, transformer: ...>
# so far so good
#But:
$> User.where_clause1.where_clause2
=> #<MongoMapper::Plugins::Querying::DecoratedPluckyQuery
app_ids: {"$in"=>[5, 42, 23, 44, 87]}, transformer: ...>
내가 안으로 $in
두 개의 절을 체인 경우, 잘난는 app_ids에 노동 조합을 수행하고 두 $in
절을 병합합니다. 나는 대신 교차로를 원합니다 : [5]
.
어떻게하면됩니까? 나는 User.where(...).andWhere(...)
을 시도했지만 그것이 존재하지 않습니다. 수동으로 두 app_ids 목록을 직접 교차시키고 싶지 않습니다.