Question

The code snippet shown below is supposed to be used to retrieve some data from database.

import anorm._

object Instruction {

 def findAll(date:String):List[RealTimeInstruction]={

    query = SQL("""
                select * from instructions where date > {dd}
                """).on("dd"->date)
 }

}

Then I would like to use pattern matching to execute the query and process the results. However, when I attemp to use query.map(...) I get the following:

value map is not a member of anorm SimpleSql.

How can I do it?

Was it helpful?

Solution

You need to create a ResultSetParser to parse the result set into somehting you can pattern match on. perhaps something like

val rowParser : RowParser[String~Date] = get[String]("instructions.name")~get[Date]("instructions.date")
val resultSetParser = rowParser *
(query as resultSetParser) map { case name~date => ... }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top