Created
September 3, 2013 20:51
-
-
Save stevef/6429393 to your computer and use it in GitHub Desktop.
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
object InjuryTester { | |
implicit val dateRW = new BSONReader[BSONDateTime,Date] with BSONWriter[Date,BSONDateTime] { | |
def read(bson: BSONDateTime): Date = new Date(bson.value) | |
def write(date: Date): BSONDateTime = BSONDateTime(date.getTime) | |
} | |
implicit val pijHandler = Macros.handler[PlayerInjury] | |
implicit val ijHandler = Macros.handler[Injury2] | |
val driver = new MongoDriver | |
lazy val connection = driver.connection(Seq("localhost")) | |
lazy val db = connection("sport195-test") | |
def findAll = { | |
val x: Future[List[Injury2]] = db.collection("injuries").find(BSONDocument()).cursor[Injury2].toList | |
val ret: Future[List[PlayerInjury]] = x.map(injLst => injLst.map(inj => inj.players.getOrElse(Seq())).flatten) | |
ret | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment