org.springframework.data.mongodb.core.query.Query.sort()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中org.springframework.data.mongodb.core.query.Query.sort方法的一些代码示例,展示了Query.sort的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.sort方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Query
类名称:Query
方法名:sort

Query.sort介绍

暂无

代码示例

代码示例来源:origin: rackerlabs/atom-hopper

nextLinkQuery.sort().on(DATE_LAST_UPDATED, Order.DESCENDING);

代码示例来源:origin: rackerlabs/atom-hopper

private List<PersistedEntry> enhancedGetFeedPage(final String feedName, final PersistedEntry markerEntry,
    final PageDirection direction, final CategoryCriteriaGenerator criteriaGenerator, final int pageSize) {
  final LinkedList<PersistedEntry> feedPage = new LinkedList<PersistedEntry>();
  final Query query = new Query(Criteria.where(FEED).is(feedName)).limit(pageSize);
  criteriaGenerator.enhanceCriteria(query);
  switch (direction) {
    case FORWARD:
      query.addCriteria(Criteria.where(DATE_LAST_UPDATED).gt(markerEntry.getCreationDate()));
      query.sort().on(DATE_LAST_UPDATED, Order.ASCENDING);
      feedPage.addAll(mongoTemplate.find(query, PersistedEntry.class, formatCollectionName(feedName)));
      Collections.reverse(feedPage);
      break;
    case BACKWARD:
      query.addCriteria(Criteria.where(DATE_LAST_UPDATED).lte(markerEntry.getCreationDate()));
      query.sort().on(DATE_LAST_UPDATED, Order.DESCENDING);
      feedPage.addAll(mongoTemplate.find(query, PersistedEntry.class, formatCollectionName(feedName)));
      break;
  }
  return feedPage;
}

代码示例来源:origin: rackerlabs/atom-hopper

final String searchString = getFeedRequest.getSearchQuery() != null ? getFeedRequest.getSearchQuery() : "";
Query queryForFeedHead = new Query(Criteria.where(FEED).is(getFeedRequest.getFeedName())).limit(pageSize);
queryForFeedHead.sort().on(DATE_LAST_UPDATED, Order.DESCENDING);
lastLinkQuery.sort().on(DATE_LAST_UPDATED, Order.ASCENDING);
final List<PersistedEntry> lastPersistedEntries = mongoTemplate.find(lastLinkQuery,
    PersistedEntry.class, formatCollectionName(getFeedRequest.getFeedName()));

代码示例来源:origin: dk.apaq.framework/criteria-mongo

q.sort().on(entry.getPropertyId(), entry.getDirection() == Sorter.Direction.Ascending ? Order.ASCENDING : Order.DESCENDING);

相关文章