mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
WriteStandardKeyValueRepo#unsetWithValues
This commit is contained in:
@@ -60,4 +60,16 @@ open class ExposedKeyValueRepo<Key, Value>(
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun unsetWithValues(toUnset: List<Value>) {
|
||||
transaction(database) {
|
||||
toUnset.flatMap {
|
||||
val keys = select { valueColumn.eq(it) }.mapNotNull { it[keyColumn] }
|
||||
deleteWhere { keyColumn.inList(keys) }
|
||||
keys
|
||||
}
|
||||
}.distinct().forEach {
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user