2016-07-23 14 views
0

Casbah Version: 2.8.0Mongo Casbah: nicht auflösen kann "++"

Das folgende Beispiel hier: http://api.mongodb.com/scala/casbah/2.0/tutorial.html#combining-multiple-dbobjects

ich unten als Import-Anweisungen.

import com.mongodb.casbah.AggregationOutput 
import com.mongodb.casbah.Imports._ 
import com.mongodb.casbah.TypeImports._ 
import com.mongodb.casbah.commons.{MongoDBList, MongoDBObject} 

Und unter ++ bekam Cannot resolve symbol ++ Fehler.

val basic = MongoDBObject(
    "id" -> "123", 
    "project" -> "pp123" 
) 

val createdTime = MongoDBObject(
    "createdTime" -> MongoDBObject(
    "$exists" -> false 
) 
) 

val query = basiC++ createdTime 

Ich habe versucht, Google aber nicht finden viel, die official documentation nicht auch nicht helfen ...

Ich glaube, ich bin nur eine Importanweisung für ++ fehlt, aber ich weiß nicht Ich weiß, welcher zu importieren ist.

Antwort

1

Eine schnelle grep der Quelle zeigt zwei ++ Methoden auf der MongoDBObject Klasse:

> 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 = { 

Die zweite hier relevant betrachtet. <% bezeichnet eine Ansicht gebunden, so dass Sie eine implizite Konvertierung von MongoDBObject zu DBObject benötigen.

> 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 

Es sieht aus wie Sie com.mongodb.casbah.Implicits._ diese erhalten importieren.

+0

jetzt gelöst, danke viel :) – keypoint

Verwandte Themen