-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updateOrInsert Method #1509
Comments
i extracted it with function: override fun insert(memberDefinition: MemberRepository.MemberDefinition) {
execInsert {
insertOrUpdate(it, memberDefinition)
}
}
override fun update(id: Long, memberDefinition: MemberRepository.MemberDefinition) {
execUpdate(id = id) {
insertOrUpdate(it, memberDefinition)
}
}
private fun MemberEntities.insertOrUpdate(
it: UpdateBuilder<Number>,
memberDefinition: MemberRepository.MemberDefinition
) {
it[email] = memberDefinition.email
it[password] = memberDefinition.password
it[displayName] = memberDefinition.displayName
it[introduce] = memberDefinition.introduce
it[profileDog] = memberDefinition.profileDog.name
it[role] = memberDefinition.role.name
it[status] = memberDefinition.status.name
}
If you want to automate this, i think you can create a class that makes dsl with reflection. However, I think that exposed is a light-weight DSL/DAO. I wish this was supported too, but It seems difficult. So I using Spring Framework, and expecting spring-data-exposed to appear and support it 😅 Does anyone else have any good ideas? |
Your solution seems to be a good one, but yeah, it would be nice if it came with the API :p |
Hi everyone! I'm currently having some questions about this piece of code created by me:
Right now I would have no issue with repeating the assignation of the variables, but what will happen with, let's say 64 variables? Do I need to create 128 assignations? I think it would be better a
updateOrInsert
method that replaces my example so I can just do this:I couldn't find something similar in the Wiki or the code, so if someone knows a better way to do this or if it's possible to implement it into Exposed it would be cool ^^
The text was updated successfully, but these errors were encountered: