I am using the SANE stack, which consists of Sails and Emberjs. I am also using MongoDB as a datastore.
When I do something like the following on the Sailsjs side of things;
Parent.find(req.query.id).populate('children').exec(function(err, parent){
console.log('children.length = ' + parent[0].children.length);
});
I get 212
But when I do something like the following on the Emberjs side of things;
parent.get('children').then(function(children){
console.log('children.length = ' + children.length);
});
I get 30.
As a matter of fact, once the number of records goes over 30, it does not matter ember will only return 30 records.
Is there some way to get the rest of the records? I actually need to records so I can sort and calculate some things. I am not just displaying them.
Any help would be greatly appreciated.
That's because the default response limit in Sails is 30 records. It's there obviously so that if you have 10k or a million rows you don't make some normal request and accidentally dump out your entire database to the client and crash everything.
This is documented here:
http://sailsjs.org/documentation/reference/configuration/sails-config-blueprints
defaultLimit (default: 30)
The default number of records to show in the response from a "find" action. Doubles as the default size of populated arrays if populate is true.
It's also documented in the config/blueprints.js
file in your sails app:
https://github.com/balderdashy/sails-generate-backend/blob/master/templates/config/blueprints.js#L152-L160.
Here is the relevant code: https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/actionUtil.js#L291
defaultLimit
in your config/blueprints.js
fileOR
&limit=<number>
to your http request URL