https://kotlinlang.org logo
#exposed
Title
# exposed
f

Fernando Sanchez (Perraco Labs)

03/29/2024, 9:31 AM
I am utilizing a base class in Exposed to maintain common fields across different tables. Here's how I've structured it:
Copy code
open class TimestampedTable(name: String) : Table(name = name) {
    val createdAt = datetime(name = "created_at").defaultExpression(CurrentDateTime)
    val updatedAt = datetime(name = "updated_at").defaultExpression(CurrentDateTime)
}

object SomeTable : TimestampedTable(name = "some_table_name") {
    // Additional fields.
}
This approach works well for me, with no issues so far. My question is if there are any additional considerations or potential pitfalls I should be aware of when using inheritance in this manner with the Exposed framework.
p

phobe

04/03/2024, 2:44 AM
I have done something similar for the last 4 years or so… doesn’t mean it is “ok” but works great