Pavan Andhukuri
Pavan Andhukuri

Reputation: 1617

Scala - Play Framework - Reactive Mongo - Service Layer

Is there a way to use reactiveMongoApi in the service layer. I have tried creating a class and tried to create a collection with the following syntax.

def collection = reactiveMongoApi.database.map( _.collection[JSONCollection]("persons"));

But it is also expecting an implicit parameter called execution context, which is from the ControllerComponents object.

Similar is the case when I try to do a find over the collection, the api expects the following implicit variables to be present which are part of MongoController

(implicit swriter: pack.Writer[S], pwriter: pack.Writer[J])

So, is there a way to have a Service Layer/DAO layer for reactivemongo? Attempt is to keep the controller code clean.

Upvotes: 1

Views: 132

Answers (1)

stainlessbaby
stainlessbaby

Reputation: 23

You may need to import scala.concurrent.ExecutionContext._

Upvotes: 0

Related Questions