I am new in spray.
I am using spray 1.3 with mongodb database.
For mongodb i use casbah driver.
import com.mongodb.casbah.{MongoClient, MongoCollection, MongoConnection}
import config.Configuration
object MongoFactory extends Configuration{
private val USERS = "users"
val mongoClient = MongoClient(mongodbHost, mongodbPort)
val db = mongoClient(mongodbName)
val USER_COLLECTION = db(USERS)
}
I use above object for making connection to mongodb.
def insert(user: User) = {
val doc = UserMongoMap.toBson(user)
MongoFactory.USER_COLLECTION.insert(doc)
}
And this is my Repository class.
Is this implementation is correct? Or I need to change this according to spray for performance?
Please suggest me.