我最近了解到,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);更多推荐
发布评论