鉴于以下使用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”)。)
答案 0 :(得分:2)
尝试映射:
query.filter{ case (contact, maybePhone) => maybePhone.map(_.areaCode === "212") }