scala slick method I can not understand so far

后端 未结 2 442
滥情空心
滥情空心 2020-11-27 09:25

I try to understand some Slick works and what it requires.

Here it an example:

package models

case class Bar(id: Option[Int] = None, name: String)

         


        
2条回答
  •  醉酒成梦
    2020-11-27 10:14

    Since no one else has answered, this might help to get you started. I don't know Slick very well.

    From the Slick documentation:

    Lifted Embedding:

    Every table requires a * method contatining a default projection. This describes what you get back when you return rows (in the form of a table object) from a query. Slick’s * projection does not have to match the one in the database. You can add new columns (e.g. with computed values) or omit some columns as you like. The non-lifted type corresponding to the * projection is given as a type parameter to Table. For simple, non-mapped tables, this will be a single column type or a tuple of column types.

    In other words, slick needs to know how to deal with a row returned from the database. The method you defined uses their parser combinator functions to combine your column definitions into something that can be used on a row.

提交回复
热议问题