I am trying to figure out how to write the following Mongo query in a complex query: {$or:[ {field:{$in:[X]}} , {field:{$size:0}}]}
Currently my query builder looks like this: https://gist.github.com/735099
Everything commented out is what I have tried and not been successful with. The closest I was able to get was this query[:dma_codes] = {'$or' => [{'dma_codes' => {'$in' => [@bid_request[:geo][:dma]]}},{'dma_codes' => { '$size' => 0}}] }
I was still getting the following error:
Read error: #<NoMethodError: undefined method `name' for #<Mongo::OperationFailure: invalid operator: $or>>
Mongo::OperationFailure - invalid operator: $or:
Is there something I am missing about constructing this query?
I think you want this:
But I don’t know ruby very well.