This repository has been archived by the owner on Jan 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
package.scala
42 lines (36 loc) · 1.92 KB
/
package.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package se.radley.plugin
import play.api._
import com.mongodb.casbah.MongoCollection
import com.mongodb.casbah.gridfs.GridFS
import play.api.Play.current
package object salat {
/**
* Returns a MongoCollection
* @param collectionName The MongoDB collection name
* @param sourceName The configured source name
* @return MongoCollection
*/
def mongoCollection(collectionName: String, sourceName:String = "default")(implicit app: Application): MongoCollection = {
app.plugin[SalatPlugin].map(_.collection(collectionName, sourceName)).getOrElse(throw new PlayException("SalatPlugin is not registered.", "You need to register the plugin with \"500:se.radley.plugin.salat.SalatPlugin\" in conf/play.plugins"))
}
/**
* Returns a capped MongoCollection
* @param collectionName The MongoDB collection name
* @param size The capped collection size
* @param max the capped collection max number of documents
* @param sourceName The configured source name
* @return MongoCollection
*/
def mongoCappedCollection(collectionName: String, size: Long, max: Option[Long] = None, sourceName:String = "default")(implicit app: Application): MongoCollection = {
app.plugin[SalatPlugin].map(_.cappedCollection(collectionName, size, max, sourceName)).getOrElse(throw new PlayException("SalatPlugin is not registered.", "You need to register the plugin with \"500:se.radley.plugin.salat.SalatPlugin\" in conf/play.plugins"))
}
/**
* Returns a GridFS bucket
* @param bucketName The GridFS bucket name
* @param sourceName The configured source name
* @return GridFS
*/
def gridFS(bucketName: String, sourceName:String = "default")(implicit app: Application): GridFS = {
app.plugin[SalatPlugin].map(_.gridFS(bucketName, sourceName)).getOrElse(throw new PlayException("SalatPlugin is not registered.", "You need to register the plugin with \"500:se.radley.plugin.salat.SalatPlugin\" in conf/play.plugins"))
}
}