【问题标题】:Add maximum size limit and direction to findAllByTypeAndCreatedAtAfter() mongodb method为 findAllByTypeAndCreatedAtAfter() mongodb 方法添加最大大小限制和方向
【发布时间】:2020-05-20 10:46:13
【问题描述】:

是否可以制定一个像下面这样返回列表1)of max size n的查询方法,

包含 2) createdAfter a specific time (Instant) at DESC order 的 Appliance 对象,

3) they are of a specific TypeEnum。我已经确定了1st2nd 的要求,但是

我还没有找到如何添加max sizedirectionrestrictions。

<T extends Appliance> List<T> findAllByTypeAndCreatedAtAfter(ApplianceTypeEnum applianceTypeEnum);

【问题讨论】:

标签: java spring mongodb spring-boot java-8


【解决方案1】:

你可以这样做:

<T extends Appliance> List<T> findFirst3ByTypeAndCreatedAtAfterDesc(ApplianceTypeEnum applianceTypeEnum);

你可以阅读更多关于 Spring Derived Queries HERE

【讨论】:

  • 谢谢!是否可以使最大尺寸(在这种情况下为三个)动态?
  • 据我所知,您可以将排序顺序作为参数传递,但我不确定是否为最大尺寸。在这种情况下,我总是使用原生查询。
猜你喜欢
  • 2013-07-19
  • 2018-12-21
  • 2013-06-04
  • 1970-01-01
  • 2019-12-19
  • 1970-01-01
  • 2014-04-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多