Returns parsed column.
Returns parsed column.
Column position from 1 to n
Column mapping
import anorm.Column.columnToString // mapping column to string val res: (String, String) = SQL("SELECT * FROM Test").map(row => row(1) -> row(2) // string columns #1 and #2 )
Returns parsed column.
Returns parsed column.
Column name
Column mapping
import anorm.Column.columnToString // mapping column to string val res: (String, String) = SQL("SELECT * FROM Test").map(row => row("code") -> row("label") // string columns 'code' and 'label' )
Returns row as T
.
Returns row as T
.
import anorm.SqlParser.{ int, str } val parseOnlyFirstRow = SQL"SELECT * FROM Table".withResult(_.map(_.row.as( str("foo") ~ int(2) map { case a ~ b => b -> a }))) // Either[List[Throwable], Option[Try[(Int, String)]]] val optionalParseRes = parseOnlyFirstRow.right.map(_.flatMap(_.toOption)) // Either[List[Throwable], Option[(Int, String)]]
Row parser
Returns row as list of column values.
Returns row as list of column values.
// Row first column is string "str", second one is integer 2 val l: List[Any] = row.asList // l == List[Any]("str", 2)
#as
Returns row as dictionary of value per column name
Returns row as dictionary of value per column name
// Row column named 'A' is string "str", column named 'B' is integer 2 val m: Map[String, Any] = row.asMap // l == Map[String, Any]("table.A" -> "str", "table.B" -> 2)
#as