我正在使用SANE堆栈,它由帆和Emberjs组成。我还使用MongoDB作为数据存储。
当我在赛尔斯杰这边做一些类似的事情时;
Parent.find(req.query.id).populate('children').exec(function(err, parent){
console.log('children.length = ' + parent[0].children.length);
});我得到212
但是当我在Emberjs这边做一些类似的事情时;
parent.get('children').then(function(children){
console.log('children.length = ' + children.length);
});我有30块钱。
事实上,一旦记录的数量超过30,无关紧要的成员只会返回30条记录。
有什么办法能查到其余的记录吗?我实际上需要记录,这样我就可以排序和计算一些事情。我不只是在展示它们。
任何帮助都将不胜感激。
发布于 2015-07-02 21:09:52
解释
这是因为Sails的默认响应限制是30条记录。很明显,如果您有10k或100万行,就不会发出一些正常的请求,并且会意外地将整个数据库转储到客户端,并使所有的数据崩溃。
这里记录了这一点:
http://sailsjs.org/documentation/reference/configuration/sails-config-blueprints
defaultLimit (缺省值: 30) 响应中显示的来自"find“操作的默认记录数。如果填充为true,则双倍作为填充数组的默认大小。
它也被记录在config/blueprints.js文件中,在sails应用程序:https://github.com/balderdashy/sails-generate-backend/blob/master/templates/config/blueprints.js#L152-L160中。
以下是相关代码:https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/actionUtil.js#L291
解决方案
defaultLimit文件中的config/blueprints.js或
&limit=<number>添加到您的http请求URLhttps://stackoverflow.com/questions/31179952
复制相似问题