使用 limit 解析“or”查询将返回忽略单个查询限制的所有记录

Parse "or" query with limit returns all records ignoring limit on single query

本文关键字:查询 单个 记录 返回 解析 limit or 使用      更新时间:2023-09-26

使用 Parse "or" Query 运算符时,尝试在单个查询中使用限制时是否存在错误?他们的网站上没有关于 or 运算符与限制运算符相关的任何记录,但我想出的一个示例查询是想要获取记录的最后一次出现,以及给定类型的所有未来记录。

我像这样编写查询:

var Appointment = Parse.Object.extend("Appointment");
var Client = Parse.Object.extend("Client");
var query = new Parse.Query(Client);
query.equalTo("objectId",client.id);
//get the last appointment whose start date occurs prior to now
var pastAppointmentQuery = new Parse.Query(Appointment);
pastAppointmentQuery.matchesQuery("Clients", query);
pastAppointmentQuery.lessThanOrEqualTo("Start",new Date());
pastAppointmentQuery.descending("Start").limit(1);
//get future appointments whose start date occurs after now (no limit)
var futureAppointmentQuery = new Parse.Query(Appointment);
futureAppointmentQuery.matchesQuery("Clients", query);
futureAppointmentQuery.greaterThanOrEqualTo("Start",new Date());
var compoundQuery = Parse.Query.or(pastAppointmentQuery,futureAppointmentQuery)
.find().then(function(appts){//....});

对于今天的日期,这将返回所有先前的记录以及所有未来的记录,完全忽略"or"运算符中第一个查询施加的限制。我错过了什么,还是这是一个错误?

不幸的是,它没有在 API 文档中说明,但确实出现在开发人员指南中:

请注意,但是,我们不支持复合查询的子查询中的 GeoPoint 或非过滤约束(例如,近、在 GeoBox 内、限制、跳过、升序/降序、包含)。