Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1997

Add support to return the single deleted item for a deleteBy query method

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Sprint:
      Lovelace RC1, Lovelace GA, Lovelace SR1, Moore RC1, Moore RC2

      Description

      Please add possibility to delete and return only one item.
      Right now it possible to delete and return list of deleted items. For example:

      public interface PersonRepository extends MongoRepository<Person, String> {
        List<Person> deleteByLastname(String lastname);     
      }
      

      But it will be great to have possibility to get only one item if it exists. So it also provides possibiltiy to nicely handle in the REST api situations when user reqeusted deletion of the item that dosen't exists.

      So the methods will looks like:

      public interface PersonRepository extends MongoRepository<Person, String> {
          Optional<Person> deleteByLastname(String lastname);
      
          Optional<Person> deleteById(String id);
      }
      

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              Hronom Eugene Tenkaev
              Last updater:
              Christoph Strobl
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: