Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of results of find-feature in sails.js restful api (in newer versions)

I started using the sails.js framework a few months ago because I need it's restful API.

In the first version a simple "http://domain.com:1337/mymodel" returned all datasets of the connected MySQL-database, however, after an update to V 0.10.xx it returns only the first 30 results.

I searched the sails.js changelog, documentation and various examples around the web and tried several ideas but I can't figure out how to force sails.js to return **all* results again.

Has anybody a solution for this?

like image 226
AuxBurger Avatar asked May 20 '14 05:05

AuxBurger


2 Answers

defaultLimit: -1 brings back all rows

like image 26
Sam Bateman Avatar answered Jan 04 '23 11:01

Sam Bateman


Use sails.config.blueprints.defaultLimit for general record limits. This also serves as the default limit for populated associations. There's technically no way at the moment to specify "no limit" for blueprints, but you can set the limit to the max number value as long as you don't have more than 9 quadrillion records :)

config/blueprints.js

defaultLimit: Number.MAX_VALUE // Set to highest possible value

Use populate_limit in your route config options to set the populate limit on a per-route basis.

config/routes.js

"GET /user": {blueprint: populate_limit: 10}

Use populate_[alias]_limit in your route config options to set the populate limit for a particular association on a per-route basis (e.g. populate_pets_limit: 10)

config/routes.js

"GET /user": {blueprint: 'find', limit: 20, populate_limit: 10, populate_pets_limit: 5}

I'll make sure this all gets added to the docs!

like image 198
sgress454 Avatar answered Jan 04 '23 11:01

sgress454