I am using <https://github.com/JetBrains/Exposed>
# ktor
z
e
That object is not serializable. What content negotiation are you using?
I tried using ktor+exposed for a side project with kotlinx.serialization and had:
Copy code
@Serializable
data class ChecklistResponse(
    val id: UUID, // requires custom serializer
    val name: String
)

class Checklist(id: EntityID<UUID>) : UUIDEntity(id) {
    companion object: UUIDEntityClass<Checklist>(Checklists)
    var name by Checklists.name
    val items by ChecklistItem referrersOn ChecklistItems.checklist
}

suspend fun getChecklists(): List<ChecklistRes> {
    return db.transaction { Checklist.all().map {
        ChecklistResponse(it.id.value, it.name) }
    }
}
i can then
call.respond(getChecklists())
There are probably nicer solutions but it works well enough and by having the response class separately I can provide a consistent API when I need to make changes to my DAO.
z
@Eric Grimsborn Sorry for the late response. As content negotiation I use
Copy code
install(ContentNegotiation) {
        gson {
        }
    }
Aha....I have to manually serialize it
Thanks a lot for your help
j
Ey @zero_coding, I’ve published a basic example of how to do all of these basic tasks. Have a look here: https://github.com/mathias21/KtorEasy
👍 1