【发布时间】:2014-09-22 17:04:12
【问题描述】:
我打算在 Play 过滤器中使用 ReactiveMongo,我该怎么做?
我只能找到在 Controller 中使用 ReactiveMongo 的示例。 如何在 Play 过滤器中访问 db.collection?
【问题讨论】:
标签: mongodb filter playframework-2.0 reactivemongo
我打算在 Play 过滤器中使用 ReactiveMongo,我该怎么做?
我只能找到在 Controller 中使用 ReactiveMongo 的示例。 如何在 Play 过滤器中访问 db.collection?
【问题讨论】:
标签: mongodb filter playframework-2.0 reactivemongo
感谢 Stéphane Godbillon 在 ReactiveMongo 谷歌小组中的回答:
您可以在您的过滤器中调用对象
ReactiveMongoPlugin(在play.modules.reactivemongo 包中)上的connection。
val connection = ReactiveMongoPlugin.connection(play.api.Play.current)
val db = connection("your-db")
def collection: JSONCollection = db.collection[JSONCollection]("your-collection")
【讨论】: