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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 3.0 M3 (Neumann)
    • Component/s: None
    • Labels:

      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:
            cstrobl Christoph Strobl
            Reporter:
            Hronom Eugene Tenkaev
            Last updater:
            Mark Paluch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: