zero_coding
08/28/2020, 12:45 PMEric Grimsborn
08/28/2020, 12:52 PM@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.zero_coding
08/28/2020, 4:37 PMinstall(ContentNegotiation) {
gson {
}
}
jorge.rego
08/28/2020, 7:11 PM