0

我有几个约束的查询:

ParseQuery < ParseObject > requestsQuery = ParseQuery.getQuery(ParseConstantsUtil.CLASS_REQUEST);
requestsQuery.whereContains(ParseConstantsUtil.REQUEST_AUTHOR, currentUser.getObjectId());
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Approved");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_READ, false);
try {
 List < ParseObject > requestsList = requestsQuery.find();
 return listSize(model, requestsList);
} catch (ParseException e) {
 e.printStackTrace();
}

其中一个约束恰好与我数据库中的同一列相关:

requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Approved");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected");

以上似乎不起作用。如何使用 ParseQuery 对同一数据库列进行 OR 查询?

requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected" || "Approved");
4

1 回答 1

1

使用ParseQuery#whereContainedIn

List<String> vals = new ArrayList<>();
vals.add("Rejected");
vals.add("Approved");
requestsQuery.whereContainedIn((ParseConstantsUtil.REQUEST_STATUS, vals);

有关更多信息,请参阅api 文档

于 2017-04-06T13:52:18.503 回答