MongoDB Spring字段之间的数据比较 [英] MongoDB Spring data comparison between fields

查看:237
本文介绍了MongoDB Spring字段之间的数据比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在各个字段之间进行比较,但似乎不适用于spring数据:

I'm trying to simply do a comparison between my fields but it doesn't seems to work with spring data :

query.addCriteria(Criteria.where("active").gt("limit"));

有效和限制是我收藏的2个字段,我想显示所有超出限制的字段。每个项目的限制都不同,所以我不能做gt(200)。...

Active and limit are 2 fields of my collection, and I wand to display all fields that exceed the limit. This limit is different for each item so I cannot do gt(200) for example...

总有办法做到这一点?

推荐答案

您可以使用Java驱动程序并发出 $ where 查询:

You can fall back to your java driver and issue a $where query:

 DBObject obj = new BasicDBObject();
 obj.put( "$where", "this.active > this.limit");
 ...

无论如何,您都必须发出其中命令

Anyway, you will have to issue a where command

考虑了警告段落

这篇关于MongoDB Spring字段之间的数据比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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