I have an experimental approach in a private proje...
# exposed
o
I have an experimental approach in a private project, need to extract it and publish. Basically, it looks like this: this is the query
Copy code
val personByIdQuery = query(PersonTable).where { PersonTable.id eq id }
then we bind the query to types
Copy code
val personModel = personByIdQuery.bindTo<Person> {
            bind(Person::place, placeQuery) 
            bindMany(Person::contacts, contactsQuery)
        }
and types involved being simple interfaces like
Copy code
interface Person {
    val id: Long
    val login: String
    val firstName: String
    val lastName: String
    val contacts: Iterable<Contact>
    val place: Place
}
and then finally executing a model in a transaction:
Copy code
val person = db.transaction { personModel.execute() }
which gives us instance of type Person