通过Casbah的正则表达式找到

sin*_*aan 7 scala mongodb casbah mongodb-scala

如何使用正则表达式Collection#find(/* HERE */):

val coll = MongoConnection()("foo")("bar")
for(x <- coll.find("name" -> ".*son$".r)) {
   // some operations...
}
Run Code Online (Sandbox Code Playgroud)

Bre*_*ams 14

你很亲密,你只需要把你的条件包裹起来MongoDBObject().

我们不得不<key> -> <value>在很多地方进行隐式转换,因为它们很难正确捕获并且破坏了其他代码.

他们可能会回到2.1.

改为:

val coll = MongoConnection()("foo")("bar")
for(x <- coll.find(MongoDBObject("name" -> ".*son$".r))) {
   // some operations...
}
Run Code Online (Sandbox Code Playgroud)