0

I am going to use ReactiveMongo in Play filter, How can i do this?

I can only find sample for using ReactiveMongo in Controller. How can i access to db.collection in a Play filter?

Saeed Zarinfam
  • 9,818
  • 7
  • 59
  • 72

1 Answers1

0

Thanks to Stéphane Godbillon for his answer in ReactiveMongo google group:

You can call the connection on the object ReactiveMongoPlugin (in the package play.modules.reactivemongo) in your filter.

  val connection =  ReactiveMongoPlugin.connection(play.api.Play.current)
  val db = connection("your-db")

  def collection: JSONCollection = db.collection[JSONCollection]("your-collection")
Saeed Zarinfam
  • 9,818
  • 7
  • 59
  • 72