-
-
Save domdorn/e5d2b09ab98ab4f7745857d8ee8e79fe to your computer and use it in GitHub Desktop.
Slick PostgreSQL List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait MyPostgresProfile | |
extends ExPostgresProfile | |
with PgArraySupport | |
with PgDate2Support | |
with PgRangeSupport | |
with PgHStoreSupport { | |
def pgjson = "jsonb" | |
// Add back `capabilities.insertOrUpdate` to enable native `upsert` support; for postgres 9.5+ | |
override protected def computeCapabilities: Set[Capability] = | |
super.computeCapabilities + slick.jdbc.JdbcCapabilities.insertOrUpdate | |
override val api = MyAPI | |
object MyAPI extends API with ArrayImplicits with DateTimeImplicits with RangeImplicits with HStoreImplicits { | |
val strSimpleJdbcArrayListType: SimpleArrayJdbcType[String] = new SimpleArrayJdbcType[String]("text") | |
implicit val strListTypeMapper: JdbcType[List[String]] = | |
strSimpleJdbcArrayListType.to(_.toList) | |
// here we | |
implicit val useCaseListTypeMapper: JdbcType[List[UseCase]] = strSimpleJdbcArrayListType | |
.mapTo[UseCase](str => UseCase.of(str), uc => uc.label) | |
.to(_.toList) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment