问题描述
我正在使用 Mongo Scala Driver 从 MongoDb 读取文档。我有以下方法返回 Future[List[T]]
def findAll(): List[Future[List[T]] = {
db.getCollection(collectionName)
.find(queryObject)
.toFuture()
.map{
results => results.map(/* converting result to T */).toList
}
}
问题:
有什么方法可以代替 List,这个方法可以返回 Iterator[T]
或 Future[Iterator[T]]
吗?
文档提到了 iterating the results via the subscribe method
,但我找不到使用此 subscribe
方法来实现我的用例的任何具体实现或示例。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)