查询搜索两次返回相同的结果(query search returning same result twice)

编程入门 行业动态 更新时间:2024-10-25 22:24:04
查询搜索两次返回相同的结果(query search returning same result twice)

我最近了解到,azure移动服务将其查询搜索限制为50(如果更改默认值,则为1000),但我的应用程序需要能够访问无限制的记录。 我创建此服务以返回包含所有记录的列表。 我做了跳过计数1,因为我想确保它在小规模上工作之前做了50之类的跳过计数。在调试这段代码之后,它继续返回两个相同的记录,其中一个不同。 我的数据库中有三个完全不同的记录,所以我很困惑,为什么它会两次拿起其中一个。 我确保在提出请求时跳过量是0,1,2。

return new Promise(function(resolve, reject) { var x = 0 var total = 1; list = []; console.log(list.length); while(x <= 3){ x++; var query = table.where(where).includeTotalCount().skip(skipAmount).take(1).read().done(function (results) { total = results.totalCount; if(results[0] != undefined) { for (var i = results.length - 1; i >= 0; i--) { list.push(results[i]); console.log(results[i]); } } else { resolve(list); } }, function (err) { reject(err); }); skipAmount++; } }); } }

I recently learned that azure mobile services limits their query search to 50 (or 1000 if you change the default), but my app needs to be able to access unlimited records. I created this service to return a list that contains all of the records. I made the skip count 1 because I wanted to make sure it worked on a small scale before doing a skip count like 50. After debugging this code it keeps returning two of the same records with one of them different. There are three completely different records in my database so I am confused why it is picking up one of them twice. I made sure that when the request was made that skip amount was either 0,1,2.

return new Promise(function(resolve, reject) { var x = 0 var total = 1; list = []; console.log(list.length); while(x <= 3){ x++; var query = table.where(where).includeTotalCount().skip(skipAmount).take(1).read().done(function (results) { total = results.totalCount; if(results[0] != undefined) { for (var i = results.length - 1; i >= 0; i--) { list.push(results[i]); console.log(results[i]); } } else { resolve(list); } }, function (err) { reject(err); }); skipAmount++; } }); } }

最满意答案

您可能需要使用.orderBy()或.orderByDescending()查询方法来确保返回已排序的数据。

table .where(where) .orderBy('updatedAt') .includeTotalCount() .skip(skipAmount) .take(1) .read() .then(success, failure);

You may need to use the .orderBy() or .orderByDescending() query methods to make sure that the sorted data are returned.

table .where(where) .orderBy('updatedAt') .includeTotalCount() .skip(skipAmount) .take(1) .read() .then(success, failure);

更多推荐

本文发布于:2023-08-07 16:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464895.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两次   query   search   returning   result

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!