Slick 3.2: Filtering on columns from left-joined table

Given the following using 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 is a Rep[Option[PhoneTable]]. How can I filter on its properties? (Something like maybePhone.contains(_.areaCode === "212").)

Upvotes: 2

Views: 853

Answers (1)

Dmytro Mitin
Dmytro Mitin

Reputation: 51658

Try mapping:

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

Upvotes: 2

Related Questions