Unpack or Map Rep[T] to a Rep[S]

23 views
Skip to first unread message

j.barrett Strausser

unread,
Aug 14, 2015, 11:03:15 AM8/14/15
to Slick / ScalaQuery
Apologies if my title makes no sense. I was not sure how to phrase my questions. I do feel it is trivial so please point to the relevant docs if I have missed something.

I have table named WebRecords with case class corresponding to something like case class WebRecordsRow(uri:Option[java.net.URI] ...... )

I want to write something like

WebRecords.filter(_.uri.getHost() === "host of interest")

Obviously that isn't the way to do it.

Here is my mapper

implicit val uriColumnType = MappedColumnType.base[java.net.URI, String](
    { u => u.toString},
    { t => new URI(t)}
    )


Can I override or implement a LIKE  operator for that mapper? Any docs on that?


Thanks,

-b

Anthony Wong

unread,
Aug 17, 2015, 2:10:09 AM8/17/15
to Slick / ScalaQuery
With the mapper you have, you should be able to do:

WebRecords.filter(_.uri === new URI("host of interest")) 
Reply all
Reply to author
Forward
0 new messages