I would like to perform a query using casbah in order to find all objects that have a certain field not set (the field does not exist) or the field has a particular value.
I have tried using
val query = ("_id.serviceName" $in serviceNames) ++ ($or("element" $exists false), MongoDBObject("element" -> "value")))
but I obtain an error:
found com.mongodb.casbah.commons.Imports.DBObject
required (String, Any)
Is it possible to express such query?
Thanks
Looks like this may be a bug in the right-hand value filter for $or; it doesn’t appear to be accepting a preconstructed DBObject from the $exists DSL statement. It definitely should — I’m filing a bug internally to fix this; in the meantime you can construct this by doing the “$exists” statement by hand:
Sorry for the trouble… I’ve created a bug entry for this to correct for the next release.