Scala 为什么$eq在casbah中的行为与$ne不同?
为什么$eq在casbah中的行为与$ne不同Scala 为什么$eq在casbah中的行为与$ne不同?,scala,casbah,Scala,Casbah,为什么$eq在casbah中的行为与$ne不同 import com.mongodb.casbah.Imports._ object O{ val x = "user" $ne "bwmcadams" // Compile fine val y = "user" $eq "bwmcadams" // fails to compile: value = is not a member of string } 由以下各项构成: <dependency>
import com.mongodb.casbah.Imports._
object O{
val x = "user" $ne "bwmcadams" // Compile fine
val y = "user" $eq "bwmcadams" // fails to compile: value = is not a member of string
}
由以下各项构成:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah-core_2.10</artifactId>
<version>2.6.0</version>
</dependency>
org.mongodb
casbah-core_2.10
2.6.0
在更高版本的Casbah中添加了$eq
操作符。尝试将您的Casbah版本更改为2.6.3。请尝试->
(作为常规元组)而不是$eq
。MongoDB中没有$eq
运算符:--equality是默认运算符
更新:看起来他们已经删除了从元组到DBObjects的转换。尝试常规地图:
val y: DBObject = Map("user" -> "bwmcadams")
更新2:查看cmbaxter的答案——他们确实在2013年7月添加了
$eq
作为运营商,但你真的不需要使用它。嘿,你说得对。我在看旧的API文档。但是,它没有做任何有趣的事情(只是包装了一个常规的DBObject):看起来就是这样。旁注:看起来casbah升级到了3.0.0,但只适用于scala 2.9.0,遗憾的是…casbah 3.0.0从未正式发布,而是成为了casbah 2.3 iirc