升级到ReactiveMongo 0.12.RC3时类型不匹配

时间:2016-09-07 18:29:24

标签: scala reactivemongo play-reactivemongo

我目前正在升级到0.12.RC3,希望修复我遇到的following issue。升级后,我收到了1. If value range < 10, bubble-sort the array. 2. Else find the midpoint of the range, split the array into two pieces (values above and below the midpoint) and recur on each piece. Append the two pieces. 方法的弃用警告。

所以我离开了:

collect

要:

def find(query: JsObject = Json.obj())(implicit reader: Reads[T]): Future[List[T]] = {
    collection.flatMap(_.find(query).cursor[T](ReadPreference.nearest).collect[List]())
}

然而,遗憾的是我收到以下错误:

  

类型不匹配,预期:(​​JSONCollection)=&gt;未来[NotInferedS]   实际:(JSONCollection)=&gt;任何

1 个答案:

答案 0 :(得分:5)

我认为你缺少一些编译器消息,应该看到类似的东西:

  (maxDocs: Int,stopOnError: Boolean)(implicit cbf: scala.collection.generic.CanBuildFrom[List[_],T,List[T]], implicit ec: scala.concurrent.ExecutionContext)scala.concurrent.Future[List[T]] <and>
  (maxDocs: Int,err: reactivemongo.api.Cursor.ErrorHandler[List[T]])(implicit cbf: scala.collection.generic.CanBuildFrom[List[_],T,List[T]], implicit ec: scala.concurrent.ExecutionContext)scala.concurrent.Future[List[T]]
 cannot be applied to (Int, reactivemongo.api.Cursor.ErrorHandler[Any])
Error occurred in an application involving default arguments.
           collection.flatMap(_.find(query).cursor[T](ReadPreference.nearest).collect[List](Int.MaxValue, Cursor.FailOnError()))

这意味着在这种情况下,如果您想使用新的collect而不是弃用的ErrorHandler,则需要使用结果类型正确注释FailOnErrorFailOnError[List[T]]} :def find(query: JsObject = Json.obj())(implicit reader: Reads[T]): Future[List[T]] = collection.flatMap(_.find(query).cursor[T](ReadPreference.nearest).collect[List](Int.MaxValue, Cursor.FailOnError[List[T]]()))

abc1d02.xxx