How to reference a column by name in slick plain S

2019-09-06 13:57发布

问题:

I would like to use named references instead of positional in GetResult, so that instead of this:

implicit val getCoffeeResult = GetResult(r => Coffee(r.<<, r.<<, r.<<))

i could write something like this:

implicit val getCoffeeResult = GetResult(r => Coffee(r.get("name"), r.get("supID"),r.get("price")))

I can has named result?

回答1:

You can get it through the resultset:

r.rs.getString("name")