Exposed PostgreSQL Power User Utils
Contains PostgreSQL extensions and utilities for Exposed.
Basic jsonb
support
You get and store data using String
s, the way how you are going to serialize and deserialize your data is up to you!
Create and update PostgreSQL enums with Java enums
Upserting with Table.upsert
, batch upserting with Table.batchUpsert
Example:
transaction(test) {
// You need to create the PostgreSQL enum before creating any tables that depend on the enum
createOrUpdatePostgreSQLEnum(CharacterType .values())
SchemaUtils .createMissingTablesAndColumns(PlayerInfo )
PlayerInfo .insert {
// The jsonb column returns a String, the serialization and deserialization is up to you!
it[PlayerInfo .information] = " {\" name\" :\" MrPowerGamerBR\" }"
it[PlayerInfo .favoriteCharacter] = CharacterType .LORITTA
}
}
}
object PlayerInfo : LongIdTable() {
val information = jsonb(" information" )
val favoriteCharacter = postgresEnumeration<CharacterType >(" favorite_character" )
}
// Keep in mind that there are some reserved types in PostgreSQL
// https://www.postgresql.org/docs/current/sql-keywords-appendix.html
enum class CharacterType {
LORITTA ,
PANTUFA ,
GABRIELA
}