mongoDB大于小于符号对应:

> 大于 $gt
< 小于 $lt
>= 大于等于 $gte
<= 小于等于 $lte

要查询同一个时间多个约束可能出现的error:

org.springframework.data.mongodb.InvalidMongoDbApiUsageException:
Due to limitations of the com.mongodb.BasicDocument, you can't add a second 'createdDate' expression specified as 'createdDate:
Document{{$lt=2018-01-06}}'. Criteria already contains 'createdDate: Document{{$gte=2017-12-31}}'.

解决办法:
要查询同一个字段多个约束需要用andOperator:

Query query = new Query(
Criteria.where("ip").is(ip)
.andOperator(
Criteria.where("createdDate").lt(endDate),
Criteria.where("createdDate").gte(startDate)));


相关文章:

  • 2021-07-13
  • 2021-11-19
  • 2021-12-12
  • 2021-12-18
  • 2021-11-05
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-07-25
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案