Casbah version: 2.8.0
Following example here: http://api.mongodb.com/scala/casbah/2.0/tutorial.html#combining-multiple-dbobjects
I'm using below as import statements.
import com.mongodb.casbah.AggregationOutput
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.TypeImports._
import com.mongodb.casbah.commons.{MongoDBList, MongoDBObject}
And below ++
got Cannot resolve symbol ++
error.
val basic = MongoDBObject(
"id" -> "123",
"project" -> "pp123"
)
val createdTime = MongoDBObject(
"createdTime" -> MongoDBObject(
"$exists" -> false
)
)
val query = basic ++ createdTime
I tried to Google but didn't find much, the official documentation didn't help either...
I guess I'm just missing an import statement for ++
, but I don't know which one to import.
A quick grep of the source reveals two ++
methods on the MongoDBObject
class:
> grep -r "def ++" .
./casbah-commons/src/main/scala/MongoDBObject.scala: def ++(pairs: (String, Any)*): DBObject = {
./casbah-commons/src/main/scala/MongoDBObject.scala: def ++[A <% DBObject](other: A): DBObject = {
The second one looks relevant here. <%
denotes a view bound, so you need an implicit conversion from MongoDBObject
to DBObject
.
> grep -r "implicit .*: DBObject =" .
./casbah-commons/src/main/scala/Implicits.scala: implicit def map2MongoDBObject(map: scala.collection.Map[String, Any]): DBObject =
./casbah-commons/src/main/scala/Implicits.scala: implicit def unwrapDBObj(in: MongoDBObject): DBObject = in.underlying
It looks like you can import com.mongodb.casbah.Implicits._
to get this.