我想查询返回两个字段相等的文档
我从this question找到了mongodb原始查询:
db.coll.find({ $where : "this.field1 == this.field2" } );
如何使用弹簧标准执行该操作:
criteria = criteria.andOperator(
Criteria.where("successfulSent").is("true"),
Criteria.where("this.fieldOne == this.fieldTwo"));
但由于生成查询而无法正常工作:
{ ... "$and" : [ { "successfulSent" : "true"} , { "this.fieldOne == this.fieldOne " : { }}]}
答案 0 :(得分:1)
您可以尝试这种方式:
Criteria.where("$where").is("this.field1 == this.field2")
查询toString()将为:
Query: { "$where" : "this.cts == this.uts"}, Fields: null, Sort: null