Slick 3.2:过滤来自左连接的列 table
Slick 3.2: Filtering on columns from left-joined table
使用 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) => ... }
可能 Phone 是 Rep[Option[PhoneTable]]。如何过滤其属性? (类似于 maybePhone.contains(_.areaCode === "212")。)
尝试映射:
query.filter{ case (contact, maybePhone) => maybePhone.map(_.areaCode === "212") }
使用 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) => ... }
可能 Phone 是 Rep[Option[PhoneTable]]。如何过滤其属性? (类似于 maybePhone.contains(_.areaCode === "212")。)
尝试映射:
query.filter{ case (contact, maybePhone) => maybePhone.map(_.areaCode === "212") }