如何使用查询注释删除MongoRepository中的项目? [英] How to delete items in MongoRepository using query annotation?

查看:86
本文介绍了如何使用查询注释删除MongoRepository中的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MongoRepository将Spring Data与MongoDB结合使用.

I'm using Spring Data with MongoDB using MongoRepository.

我想知道是否有可能使用查询注释通过过滤器进行删除.我一直在这里和google中查找,找不到任何文档.

I was wondering if it is possible do a delete by filter using query annotation. I have been looking here and google and I cannot find any documentation.

推荐答案

@Query(value="{'id' : $0}", delete = true)
public Person deleteById (String id);

这篇关于如何使用查询注释删除MongoRepository中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆