Last active
January 5, 2017 09:45
-
-
Save gstraymond/a2d4032298c553d4bc7837e0e4288eee to your computer and use it in GitHub Desktop.
play mongo bson - SampleDataDAO.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.{Inject, Singleton} | |
import ai.snips.bsonmacros.{BaseDAO, CodecGen, DatabaseContext} | |
import scala.concurrent.ExecutionContext | |
@Singleton | |
class SampleDataDAO @Inject()(val dbContext: DatabaseContext) | |
(implicit ec: ExecutionContext) extends BaseDAO[SampleData] { | |
// generating once a codec for you case class and putting in the registry | |
CodecGen[SampleData](dbContext.codecRegistry) | |
// defining database name | |
val db = dbContext.database("sample_db") | |
// defining collection name | |
override val collection = db.getCollection[SampleData]("sample_data") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment