MongoID를 처음 사용했습니다. 내가 specification
/삽입 문서 /의 body
분야에서 $in
연산자를 사용하기 위해 노력하고있어 내 컨트롤러에서
class Vehicle
include Mongoid::Document
include Mongoid::Timestamps
##
# Relationship
embeds_one :specification
end
class Specification
include Mongoid::Document
##
# Columns
field :body, type: String
##
# Relationship
embedded_in :vehicle
end
: 나는 다음과 같은 모델을 가지고있다. Embed 문서에서 $in
연산자를 사용하는 방법은 무엇입니까? 코드 아래에서 시도했지만 작동하지 않습니다.
result += Vehicle.where(:specification.matches => { :body.in => param(:body) }) if params[:body].present?
도움이 :) @로
에 해당하는 MongoDB의 연산자를 사용할 필요가 있습니다 만 'embeds_one'은 임베디드 해시를 둘러싼 다.'Vehicle.where ('specification.body'=> ...)'가 출발점이 될 수 있습니다. –