WriteStandardKeyValueRepo#unsetWithValues

This commit is contained in:
2020-12-05 17:52:37 +06:00
parent 3ae9b3e576
commit 091cb38339
9 changed files with 74 additions and 7 deletions

View File

@@ -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)
}
}
}