org.mongodb.morphia.query.Query.filter()方法的使用及代码示例

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

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

Query.filter介绍

[英]Create a filter based on the specified condition and value.

Note: Property is in the form of "name op" ("age >").

Valid operators are ["=", "==","!=", "<>", ">", "=", "

Examples:

  • filter("yearsOfOperation >", 5)
  • filter("rooms.maxBeds >=", 2)
  • filter("rooms.bathrooms exists", 1)
  • filter("stars in", new Long[]{3, 4}) //3 and 4 stars (midrange?)}
  • filter("quantity mod", new Long[]{4, 0}) // customers ordered in packs of 4)}
  • filter("age >=", age)
  • filter("age =", age)
  • filter("age", age) (if no operator, = is assumed)
  • filter("age !=", age)
  • filter("age in", ageList)
  • filter("customers.loyaltyYears in", yearsList)

You can filter on id properties if this query is restricted to a Class.
[中]根据指定的条件和值创建筛选器。
注:物业的形式为“名称op”(“年龄>”)。
有效运算符为[“=”、“=”、“!=”、“<>”、“>”、“=”、”
例如:
*过滤器(“yearsOfOperation>”,5)
*过滤器(“rooms.maxBeds>=”,2)
*过滤器(“房间。浴室存在”,1)
*过滤器(“星在”,新长[]{3,4})//3和4星(中程?}
*过滤器(“数量模式”,新长[]{4,0})//客户以4个包装订购)
*过滤器(“年龄>=”,年龄)
*过滤器(“age=,age)
*过滤器(“年龄”,年龄)(如果没有运算符,则假定为)
*过滤器(“年龄!=”,年龄)
*过滤器(“年龄范围”,年龄列表)
*筛选(“customers.loyaltyYears in”,yearsList)
如果此查询仅限于类,则可以根据id属性进行筛选。

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public List<JobPo> getDeadJobs(long deadline) {
  Query<JobPo> query = template.createQuery(JobPo.class);
  query.filter("gmtModified < ", deadline);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public List<JobPo> getDeadJobs(long deadline) {
  Query<JobPo> query = template.createQuery(JobPo.class);
  query.filter("gmtModified < ", deadline);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public List<JobPo> getDeadJob(String taskTrackerNodeGroup, long deadline) {
  String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(true).
      filter("gmtCreated < ", deadline);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public List<JobPo> getDeadJob(String taskTrackerNodeGroup, long deadline) {
  String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(true).
      filter("gmtCreated < ", deadline);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

protected List<JobPo> load(String loadTaskTrackerNodeGroup, int loadSize) {
  // load
  String tableName = JobQueueUtils.getExecutableQueueName(loadTaskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(false)
      .filter("triggerTime < ", SystemClock.now())
      .order(" priority, triggerTime , gmtCreated").offset(0).limit(loadSize);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

protected List<JobPo> load(String loadTaskTrackerNodeGroup, int loadSize) {
  // load
  String tableName = JobQueueUtils.getExecutableQueueName(loadTaskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(false)
      .filter("triggerTime < ", SystemClock.now())
      .order(" priority, triggerTime , gmtCreated").offset(0).limit(loadSize);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

addCondition(query, "needFeedback", request.getNeedFeedback());
if (request.getStartGmtCreated() != null) {
  query.filter("gmtCreated >= ", request.getStartGmtCreated().getTime());
  query.filter("gmtCreated <= ", request.getEndGmtCreated().getTime());
  query.filter("gmtModified <= ", request.getStartGmtModified().getTime());
  query.filter("gmtModified >= ", request.getEndGmtModified().getTime());

代码示例来源:origin: ltsopensource/light-task-scheduler

addCondition(query, "needFeedback", request.getNeedFeedback());
if (request.getStartGmtCreated() != null) {
  query.filter("gmtCreated >= ", request.getStartGmtCreated().getTime());
  query.filter("gmtCreated <= ", request.getEndGmtCreated().getTime());
  query.filter("gmtModified <= ", request.getStartGmtModified().getTime());
  query.filter("gmtModified >= ", request.getEndGmtModified().getTime());

代码示例来源:origin: ltsopensource/light-task-scheduler

query.filter("logTime >= ", getTimestamp(request.getStartLogTime()));
query.filter("logTime <= ", getTimestamp(request.getEndLogTime()));

代码示例来源:origin: ltsopensource/light-task-scheduler

query.filter("logTime >= ", getTimestamp(request.getStartLogTime()));
query.filter("logTime <= ", getTimestamp(request.getEndLogTime()));

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> Query<T> filterExpression(final String filterExpression, Query<T> query) {
  if (filterExpression.contains("=")) {
    final String[] paramExpression = filterExpression.split("=");
    final String paramName = paramExpression[0];
    final String paramValue = paramExpression[1];
    query = query.filter("actions.parameters.name", paramName);
    query = query.filter("actions.parameters.value", Pattern.compile(paramValue));
  } else {
    query = query.filter("actions.causes.branch.branch", Pattern.compile(filterExpression));
  }
  return query;
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
@Deprecated
public <T, V> Query<T> find(final Class<T> clazz, final String property, final V value) {
  final Query<T> query = createQuery(clazz);
  return query.filter(property, value);
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public List<LGJob> getAllByAge(int days) {
  if (days <= 0) {
    days = 1;
  }
  Calendar cdate = Calendar.getInstance();
  days *= -1;
  cdate.add(Calendar.DAY_OF_YEAR, days);
  Query<LGJob> query = getDatastore().createQuery(LGJob.class).filter("createDate >=", cdate.getTime());
  return query.asList();
}

代码示例来源:origin: jzyong/game-server

public static User findByAccount(String accunt) {
  Query<User> query = userDao.createQuery().filter("accunt", accunt);
  return query.get();
}

代码示例来源:origin: com.github.ltsopensource/lts-core

@Override
public List<JobPo> getDeadJobs(long deadline) {
  Query<JobPo> query = template.createQuery(JobPo.class);
  query.filter("gmtModified < ", deadline);
  return query.asList();
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
@Deprecated
public <T, V> Query<T> find(final Class<T> clazz, final String property, final V value, final int offset, final int size) {
  final Query<T> query = createQuery(clazz);
  query.offset(offset);
  query.limit(size);
  return query.filter(property, value);
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
@Deprecated
public <T, V> WriteResult delete(final String kind, final Class<T> clazz, final V id, final WriteConcern wc) {
  return delete(find(kind, clazz).filter(Mapper.ID_KEY, id), new DeleteOptions().writeConcern(wc));
}

代码示例来源:origin: jzyong/game-server

/**
 * 获取公共邮件
 * 
 * @author JiangZhiYong
 * @QQ 359135103 2017年9月21日 下午4:12:44
 * @return
 */
public static List<Mail> getPublicMails() {
  return mailDao.createQuery().filter("type", Mail.MailType.PUBLIC_SYSTEM.ordinal()).asList();
}

代码示例来源:origin: com.github.ltsopensource/lts-core

@Override
public List<JobPo> getDeadJob(String taskTrackerNodeGroup, long deadline) {
  String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(true).
      filter("gmtCreated < ", deadline);
  return query.asList();
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getBuildBySha(final DbBackedProject<?, ?> project, final String sha, final Result result) {
  Query<DbBackedBuild> query = getQuery(project).
    field("actions.causes.sha").equal(sha);
  if (result != null) {
    query = query.filter("result", result.toString());
  }
  final DbBackedBuild build = query.get();
  associateProject(project, build);
  return (T) build;
}

相关文章