Paul at Avans Breda
10/14/2024, 11:49 AMOleg Babichev
10/14/2024, 12:34 PMArrayColumnType
is made to use array
database type that is supported by Postgres and H2 only (better to recheck).
Here is just a simple example of how to use it:
object TestTable : IntIdTable() {
val files = array<String>("files")
}
class TestEntity(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<TestEntity>(TestTable)
var files by TestTable.files
}
@Test
fun test() {
withTables(TestTable) {
TestEntity.new {
files = listOf("f1.pdf", "f2.pdf")
}
val entry = TestTable.selectAll().first()
assertEqualLists(listOf("f1.pdf", "f2.pdf"), entry[TestTable.files])
}
}
If you want to store them in another column type (like varchar
or text
) you will have to make client side conversion of the data (manually or with transform
API for example)
If you describe your case more detailed, I can try make another example)Paul at Avans Breda
10/14/2024, 12:41 PM