![JAR search and dependency download from the Maven repository](/logo.png)
com.sxtanna.database.task.builder.InsertBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Kuery Show documentation
Show all versions of Kuery Show documentation
MySQL Kotlin wrapper based on HikariCP
package com.sxtanna.database.task.builder
import com.sxtanna.database.ext.PrimaryKey
import com.sxtanna.database.type.base.SqlObject
import kotlin.reflect.KClass
import kotlin.reflect.full.findAnnotation
import kotlin.reflect.full.memberProperties
class InsertBuilder(val clazz : KClass, val table : String) {
var ignore = false
private set
var update = emptyArray()
private set
fun onDupeIgnore() : InsertBuilder {
ignore = true
return this
}
@JvmOverloads
fun onDupeUpdate(vararg column : CharSequence = arrayOf(clazz.memberProperties.find { it.findAnnotation() != null }?.name ?: "")) : InsertBuilder {
update = column.map { it.toString() }.toTypedArray()
return this
}
companion object Insert {
@JvmSynthetic
inline fun into(table : String = T::class.simpleName!!) = InsertBuilder(T::class, table)
@JvmOverloads
fun into(clazz : Class, table : String = clazz.simpleName!!) = InsertBuilder(clazz.kotlin, table)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy