val driver = new MongoDriver
val connection = driver.connection(List("localhost"))
val db = connection.database("test")
val collection = db.map(_ ("gr"))
val document = BSONDocument(
"firstName" -> "Stephane",
"lastName" -> "Godbillon",
"age" -> 29)
val future1: Future[WriteResult] = collection.insert(document)
and then[error] Sandbox/src/main/scala/ma.scala:28: object insert is not a member of package collection[error] val future1: Future[WriteResult] = collection.insert(document)[error] ^[error] one error foundWhat is going on?
I would suggest you try to declare this val with explicit type to have the compiler helping to see what it is.
The documentation is also indicating how to get a this kind of collection reference from the database ( http://reactivemongo.org/releases/0.11/documentation/tutorial/database-and-collection.html ), which itself must be resolved from the connection pool ( http://reactivemongo.org/releases/0.11/documentation/tutorial/connect-database.html ).
It's recommanded to go step by step (note that all examples are compiled).
Getting a database and a collection is pretty easy:
A collection can be resolved from the database, thanks to the collection
.