Standard practice for spray and casbah

13 views
Skip to first unread message

Dinesh Maske

unread,
May 14, 2015, 5:29:00 AM5/14/15
to spray...@googlegroups.com
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. 

Reply all
Reply to author
Forward
0 new messages