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

Joel

11/10/2020, 5:06 PM
Copy code
val fullName: String get() = listOfNotNull(firstName, lastName).joinToString(" ")

    private var cachedFullName by UserDetailsTable.fullName

    companion object : EntityClass<String, UserDetailsView>(UserDetailsTable) {
        init {
            EntityHook.subscribe { action ->
                action.toEntity(this)?.let { it.cachedFullName = it.fullName }
            }
        }
    }
Is there a cleaner way to set a computed value using the DAO?
t

tapac

11/11/2020, 7:24 AM
Is the firstName/lastName also parsed from cachedFullName?
j

Joel

11/11/2020, 3:48 PM
@tapac negative. They are set directlty.
Copy code
User.new(userId) {
  firstName = "John"
  lastName = "Doe"
}
2 Views