コードは ReactiveMongo を使用して MongoDB にリクエストを送信し、返されますFuture[BSONDocument]
が、私のコードはデータのリストを処理するため、値を取得してリストに変換する必要がありFuture[BSONDocument]
ます。
ブロックせずにそれを行うにはどうすればよいですか?
アップデ:
ReactiveMongoを使用していますRawCommand
def findLByDistance()(implicit ec: ExecutionContext) = db.command(RawCommand(
BSONDocument(
"aggregate" -> collName,
"pipeline" -> BSONArray(BSONDocument(
"$geoNear" -> BSONDocument(
"near" -> BSONArray(44.72,25.365),
"distanceField" -> "location.distance",
"maxDistance" -> 0.08,
"uniqueDocs" -> true)))
)))
で結果が出Future[BSONDocument]
ます。いくつかの単純なクエリでは、単純な変換を可能にするデフォルトのクエリビルダーを使用しました
def findLimitedEvents()(implicit ec: ExecutionContext) =
collection.find(BSONDocument.empty)
.query(BSONDocument("tags" -> "lazy"))
.options(QueryOpts().batchSize(10))
.cursor.collect[List](10, true)
基本的に、RawCommand
以前に使用したものと一致する出力タイプが必要です。