Spring数据mongo在Query中使用OR [英] Spring data mongo use OR in Query
本文介绍了Spring数据mongo在Query中使用OR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们看看有人可以帮忙解决这个问题。
Let´s see if somebody can help with this.
我想使用Spring Data mongodb的存储库,我希望使用Query注释来按值过滤find A = 10或A = 20
I want use Repository of Spring Data mongodb, and I want use Query annotation to filter the find by value A=10 or A=20
@Query("{A: 10, A:20}")
findById(int id);
Obiously,尝试制作一个AND,我需要一个OR。
Obiously "," try to make an AND, and I need an OR.
有什么想法吗?
推荐答案
我认为这可能有用
@Query("{'$or':[ {'A':10}, {'B':20} ] }")
这篇关于Spring数据mongo在Query中使用OR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文