と を使用してプロジェクトをセットアップしていplayframework 2.2.0
ますplay2-reactivemongo 0.10.0-SNAPSHOT
。次のような方法で、いくつかのドキュメントを ID でクエリしたいと思います。
def usersCollection = db.collection[JSONCollection]("users")
val ids: List[String] = /* fetched from somewhere else */
val query = ??
val users = usersCollection.find(query).cursor[User].collect[List]()
私が試したクエリとして:
Json.obj("_id" -> Json.obj("$in" -> ids)) // 1
Json.obj("_id.$oid" -> Json.obj("$in" -> ids)) // 2
Json.obj("_id" -> Json.obj("$oid" -> Json.obj("$in" -> ids))) // 3
1 番目と 2 番目は空のリストを返し、3 番目はエラーで失敗しますassertion 10068 invalid operator: $oid
。