I connect to MongoDB with Scala using :
val driver = new MongoDriver
val connection = driver.connection(List("myhost"))
val db = connection.database("mydb")
This works fine but how to integrate this with a Play controller :
@Singleton
class ReactiveController @Inject() (implicit system: ActorSystem, materializer: Materializer, val reactiveMongoApi: ReactiveMongoApi)
extends Controller with MongoController with ReactiveMongoComponents {
Do I need to inject a custom ReactiveMongoApi
with my DB configuration ?
Or do I need to modify application.conf with my DB settings ?
I'm using play 2.5 and http://reactivemongo.org/releases/0.11/documentation/tutorial/play2.html provides this code :
package api
import reactivemongo.api.{ DB, MongoConnection, MongoDriver }
trait ReactiveMongoApi {
def driver: MongoDriver
def connection: MongoConnection
def db: DB
}
But I'm unsure how to integrate it with my Play application ?
I think I'm not aware of some standard method of configuring DB sources with a Play! application ?