Rasheed Sulayman
03/16/2020, 7:39 PMdata
classes directly with exposed, something like:
object Users : Table() {}
// Get list of users
val usersList: List<User> = Users.select { Users.city.eq("a city") }
//Insert users
val allUsers: List<User> = //list of users
val aUser: User = //User instance
Users.insertAll(allUsers) // Inserts everything in to the user table
Users.insert(aUser) // Inserts a single user in to the table.
i.e Something that automatically maps/converts rows to data classes when reading stuff, and vice versa when inserting.codec
03/17/2020, 3:06 AMreturn transaction(db) {
UsersTable.select { UsersTable.email.eq(email) }
.map { User(it[UsersTable.id], email, it[UsersTable.first_name], it[UsersTable.last_name], it[UsersTable.password]) }
.singleOrNull()
}
tjohnn
03/17/2020, 7:12 AMtapac
03/17/2020, 7:18 AMRasheed Sulayman
03/17/2020, 11:27 AM.map { User(it[UsersTable.id], email, it[UsersTable.first_name], it[UsersTable.last_name], it[UsersTable.password]) }
without having to write it manually... Imagine if you have objects/data classes with 30+ fields (i.e 30+ table columns).There is <https://github.com/TouK/krush> and also you could vote and suggest for
<https://github.com/JetBrains/Exposed/issues/24#issuecomment-566725685>
Thanks @tapac, this sounds like what i'm looking for.