In Spring-data-mongodb, can we return the single deleted object from query method of repository like below
public interface MyRepository extends MongoRepository<MyObject, String>{
Optional<MyObject> deleteByXAndY(String x, String y);
}
if there will be always single document that's get deleted by above query.
I tried it but it throws exception like cant convert Long to MyObject. I think only void, long or List or Stream are supported. Is there any way to achieve what I am trying to do?