MongDB Delete in Repository
Hello all, I'm using the latest version of MongoDB *with* Repositories and trying to do something like "delete by $field". For example:
A sample bean:
Code:
@Document
public class Foobar implements Serializable {
@Id
private Long id;
private String name;
}
A sample Repository
Code:
@Document
public interface FoobarRepository extends MongoRepository<Foobar, Long>{
void deleteByName(final String name);
}
All methods inherited from MongoRepository work well...but this one that I tried to define in the interface makes Spring Data barf. Essentially, Spring Data's repository generator thinks "delete" is a field in Foobar....when in actuality, its a*verb*.
I know there is a @Query annotation I can use...but it seems to only support JSON queries...but isn't that only for *searching* and not *deleting*...is there a way I can tell Spring this query should *delete*? Is there a better way to do this?
thanks in advance,
/m