Skip to content

Commit c4d2bd5

Browse files
committed
DATACMNS-800 - Add deleteAllById to CoroutineCrudRepository.
Original pull request: #476.
1 parent ae4f036 commit c4d2bd5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ interface CoroutineCrudRepository<T, ID> : Repository<T, ID> {
132132
*/
133133
suspend fun delete(entity: T)
134134

135+
/**
136+
* Deletes all instances of the type `T` with the given IDs.
137+
*
138+
* @param ids must not be null nor contain any null values.
139+
* @throws IllegalArgumentException in case the given [ids][Iterable] or one of its items is null.
140+
* @since 2.5
141+
*/
142+
suspend fun deleteAllById(ids: Iterable<ID>)
143+
135144
/**
136145
* Deletes the given entities.
137146
*

src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryUnitTests.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ class CoroutineCrudRepositoryUnitTests {
140140
assertThat(result).isTrue()
141141
}
142142

143+
@Test // DATACMNS-800
144+
fun shouldInvokeDeleteAllById() {
145+
146+
every { backingRepository.deleteAllById(listOf("foo", "bar")) } returns Mono.empty()
147+
148+
runBlocking {
149+
coRepository.deleteAllById(listOf("foo", "bar"))
150+
}
151+
152+
verify { backingRepository.deleteAllById(listOf("foo", "bar")) }
153+
}
154+
143155
@Test // DATACMNS-1508
144156
fun shouldInvokeDeleteAll() {
145157

0 commit comments

Comments
 (0)