本文整理汇总了Java中org.mongodb.morphia.query.Query.order方法的典型用法代码示例。如果您正苦于以下问题:Java Query.order方法的具体用法?Java Query.order怎么用?Java Query.order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongodb.morphia.query.Query
的用法示例。
在下文中一共展示了Query.order方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJoinableServer
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public Server getJoinableServer(Filter filter, String uuid) {
Query<Server> query = getFilterQuery(filter);
query.and(getServerQuery().criteria("joinable").equal(true),
getServerQuery().criteria("expiry").greaterThan(System.currentTimeMillis()),
getServerQuery()
.or(new WhereCriteria("this.mpc > this.pc"),
getServerQuery().criteria("mpc").equal(0)));
query.limit(1);
query.order("pc");
query.getSortObject().put("pc", -1);
UpdateOperations<Server> updateOperations = datastore.createUpdateOperations(Server.class);
updateOperations.inc("pc", 1);
updateOperations.add("players", uuid);
Server server = datastore.findAndModify(query, updateOperations, false, false);
if (server == null)
return null;
return server;
}
示例2: filter
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
*
* @param queryCriteria - key is field and operator and value is RHS value
* eg: "Location in" => "Delhi"
* @param sortCriteria - comma separated field names. use - for descending
* order eg: "location, -status"
* @param pageInfo - contain limit and offset
* @return
*/
public List<T> filter(Map<String, Object> queryCriteria, String sortCriteria, PageInfo pageInfo) {
Query<T> query = datastore.createQuery(genericType);
for (Map.Entry<String, Object> entry : queryCriteria.entrySet()) {
query = query.filter(entry.getKey(), entry.getValue());
}
if (pageInfo == null) {
pageInfo = new PageInfo(100000, 0);
}
if (sortCriteria == null) {
sortCriteria = "_id";
}
query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
query = query.order(sortCriteria);
return query.asList();
}
示例3: pageSelect
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public PaginationRsp<JobPo> pageSelect(JobQueueReq request) {
Query<JobPo> query = template.createQuery(getTargetTable(request.getTaskTrackerNodeGroup()), JobPo.class);
addCondition(query, "jobId", request.getJobId());
addCondition(query, "taskId", request.getTaskId());
addCondition(query, "taskTrackerNodeGroup", request.getTaskTrackerNodeGroup());
addCondition(query, "submitNodeGroup", request.getSubmitNodeGroup());
addCondition(query, "needFeedback", request.getNeedFeedback());
if (request.getStartGmtCreated() != null) {
query.filter("gmtCreated >= ", request.getStartGmtCreated().getTime());
}
if (request.getEndGmtCreated() != null) {
query.filter("gmtCreated <= ", request.getEndGmtCreated().getTime());
}
if (request.getStartGmtModified() != null) {
query.filter("gmtModified <= ", request.getStartGmtModified().getTime());
}
if (request.getEndGmtModified() != null) {
query.filter("gmtModified >= ", request.getEndGmtModified().getTime());
}
PaginationRsp<JobPo> response = new PaginationRsp<JobPo>();
Long results = template.getCount(query);
response.setResults(results.intValue());
if (results == 0) {
return response;
}
if (StringUtils.isNotEmpty(request.getField()) && StringUtils.isNotEmpty(request.getDirection())) {
query.order(("ASC".equalsIgnoreCase(request.getDirection()) ? "" : "-") + request.getField());
}
query.offset(request.getStart()).limit(request.getLimit());
response.setRows(query.asList());
return response;
}
示例4: getMany
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
* @param ids
* @param sortCriteria - comma separated field names. use - for descending
* order eg: "location, -status"
* @param pageInfo - contain limit and offset
* @return
*/
public List<T> getMany(List<String> ids, String sortCriteria, PageInfo pageInfo) {
Query<T> query = datastore.createQuery(genericType);
query = query.field("_id").in(ids);
query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
query = query.order(sortCriteria);
return query.asList();
}
示例5: applyQueryFilters
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Query<DynamicBuild> applyQueryFilters(Query<DynamicBuild> query) {
query = filterBranch(query);
query = query.limit(getBuildCount());
return query.order("number");
}
示例6: fetch
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
protected Iterable<MongoActivity> fetch(Query<MongoActivity> q) {
return super.fetch(q.order(reverse(MongoActivity.TIME)));
}
示例7: fetch
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
protected Iterable<MongoTrack> fetch(Query<MongoTrack> q) {
return super.fetch(q.order(MongoTrack.RECENTLY_CREATED_ORDER));
}