特性GenericQueryBuilder中的方法游标已弃用

时间:2015-10-29 15:15:09

标签: scala reactivemongo

我正在使用"org.reactivemongo" %% "play2-reactivemongo" % "0.11.7.play24",当我编译我的proyect时,请告诉我下一个错误:

[error] /home/hector/enova/play-silhouette-reactivemongo-seed-master/app/controllers/CourseController.scala:90: method cursor in trait GenericQueryBuilder is deprecated: Use [[cursor]] function with read preference.
[error]       cursor[JsObject]
[error]       ^
[error] /home/hector/enova/play-silhouette-reactivemongo-seed-master/app/controllers/CourseController.scala:120: method cursor in trait GenericQueryBuilder is deprecated: Use [[cursor]] function with read preference.
[error]       cursor[JsObject]
[error]       ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed

第90行和第120行以粗体显示:

    val cursor: Cursor[JsObject] = collection.
      find(Json.obj("title" -> title)).
      sort(Json.obj("created" -> -1)).       
      cursor[JsObject]


    val cursor: Cursor[JsObject] = collection.
      find(Json.obj("active" -> true)).
      cursor[JsObject]

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

只需将括号添加到cursor方法即可。这将是有效的。

collection.find(...).cursor[JsObject]()