DATAMONGO-1997 - Add support to return the single deleted item for a deleteBy query method.

Added support for:

@Nullable
Person deleteSingleByLastname(String lastname);

Optional<Person> deleteByBirthdate(Date birthdate);

Mono<Person> deleteSinglePersonByLastname(String lastname);

Original pull request: #826.
This commit is contained in:
Christoph Strobl
2020-01-17 15:52:05 +01:00
committed by Mark Paluch
parent 0a2ea88f3c
commit c56a13ad00
7 changed files with 96 additions and 6 deletions

View File

@@ -301,15 +301,22 @@ The keywords in the preceding table can be used in conjunction with `delete…By
----
public interface PersonRepository extends MongoRepository<Person, String> {
List <Person> deleteByLastname(String lastname);
List <Person> deleteByLastname(String lastname); <1>
Long deletePersonByLastname(String lastname);
Long deletePersonByLastname(String lastname); <2>
@Nullable
Person deleteSingleByLastname(String lastname); <3>
Optional<Person> deleteByBirthdate(Date birthdate); <4>
}
----
<1> Using a return type of `List` retrieves and returns all matching documents before actually deleting them.
<2> A numeric return type directly removes the matching documents, returning the total number of documents removed.
<3> A single domain type result retrieves and removes the first matching document.
<4> Same as in 3 but wrapped in an `Optional` type.
====
Using a return type of `List` retrieves and returns all matching documents before actually deleting them. A numeric return type directly removes the matching documents, returning the total number of documents removed.
[[mongodb.repositories.queries.geo-spatial]]
=== Geo-spatial Repository Queries