1

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.

Pavan Andhukuri
  • 1,547
  • 3
  • 23
  • 49

1 Answers1

0

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

stainlessbaby
  • 23
  • 1
  • 8