Is there any particular reason a batchDelete doesn...
# exposed
h
Is there any particular reason a batchDelete doesn't exist?
s
Isnt that just a
deleteWhere
?
h
not exactly. You would want to pass a collection. For example you have a list of ids you want to delete.
s
Copy code
table.deleteWhere { table.id inList list }
h
ah nice didnt know you could do that
s
In our internal util libraries we keep helpers like this one below and discourage plain update and delete due to the risk of
delete where true
Copy code
fun <T : Table, C> T.safeDeleteOwnedByMany(
        ownedColumnSelect: T.() -> Column<C>,
        idsOfOwningEntities : Iterable<C>,
        owningColumn: Column<C>
) {
    val ownedColumn = ownedColumnSelect()
    require(ownedColumn.referee == owningColumn)

    deleteWhere {
        ownedColumn inList idsOfOwningEntities
    }
}
👍 1