光滑3.2:从左连接表中过滤列

时间:2017-10-28 03:50:40

标签: scala slick slick-3.0 typesafe

鉴于以下使用Slick 3.2:

val contacts = TableQuery[ContactTable]
val phones = TableQuery[PhoneTable]

val query = contacts.joinLeft(phones).on(_.contact_id === _.id)

query.filter{ case (contact, maybePhone) => ... }

maybePhone是Rep [Option [PhoneTable]]。如何过滤其属性? (像maybePhone.contains(_。areaCode ===“212”)。)

1 个答案:

答案 0 :(得分:2)

尝试映射:

query.filter{ case (contact, maybePhone) => maybePhone.map(_.areaCode === "212") }