蒙戈3.2 scalaVersion 2.11.7 活化剂1.3.9简单地得到整个集合
所以我无法简单地获取整个集合
我试图用文档的http://reactivemongo.org/页和第一连接
def connect() {
// gets an instance of the driver
// (creates an actor system)
val driver = new MongoDriver
val connection = driver.connection(List("localhost"))
// Gets a reference to the database "plugin"
val db = connection("plugin")
// Gets a reference to the collection "acoll"
// By default, you get a BSONCollection.
val collection = db("acoll")
}
到目前为止好,我有10个连接(如果我已经正确地阅读正如预期的那样)。
然后我试图修改究竟是什么“简单查询”的文件上,而是跨越的IntelliJ出来说光标[BSONDocument]已被废弃,我应该使用光标(),而不是(我做了)。
我结束了:
def getAll(collection: BSONCollection) = {
val query = BSONDocument()
val filter = BSONDocument(
"_id" -> 1
)
val futureList: Future[List[BSONDocument]] =
collection.
find(query, filter).
cursor().
collect[List]()
futureList.map { list =>
list.foreach {
doc => println(s"found document: ${BSONDocument pretty doc}")
}
}
}
现在在我的控制,我与Db.connect连接(顺便说一下,Db的是一个对象Db的{},不知道如果我应该这样做,那种Scala中,MongoDB的新播放)
var collection = Db.connect()
println("Connected to db : " + collection)
var list = Db.getAll(collection)
...
问题,Db.connect()似乎并没有返回BSONCollection但一股股
所以我在想,如果你们能够给我一个提示或某事的乞讨内像我......
很抱歉,如果这似乎是一个愚蠢的问题,但我很困惑,甚至对文档的,因为我不能建立一个单一的一块吧
感谢