Node version: 8.9.4
Sails version _(sails)_: 1.1.0
ORM hook version _(sails-hook-orm)_: 2.0.0.0-16
Sockets hook version _(sails-hook-sockets)_: 1.4.0
Organics hook version _(sails-hook-organics)_: NA
Grunt hook version _(sails-hook-grunt)_: 3.0.2
Uploads hook version _(sails-hook-uploads)_:NA
DB adapter & version _(e.g. [email protected])_: Custom Oracle
Skipper adapter & version _(e.g. [email protected])_: NA
When setting limit=-1 in the api call, sails returns the following:
Deprecated: In previous versions of Waterline, the specified
limit(-1) would work the same as if you > had omitted thelimitaltogether-- i.e. defaulting toNumber.MAX_SAFE_INTEGER. If that is what you > are intending to happen, then please just omitlimitinstead, which is a more explicit and future-proof > way of doing the same thing.
Warning: This backwards compatibility will be removed
in a future release of Sails/Waterline. If this usage
is left unchanged, then queries like this one will eventually
fail with an error.
The issue is that by default Sails limits the records to 30 if limit is not specified. The "defaultLimit" parameter in blueprint.js does not appear to work any longer. What are the current methods for returning all records for a blueprint route (single route only AND all blueprint routes)?
@abatkins Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
Hey, @abatkins!
I've done a little bit of digging in our docs, and this section of the upgrade guide seems to indicate that limit: undefined might produce the behavior you're looking for.
If that doesn't work, we recommend creating a custom action.
Not specifying limit defaults to 30. I also tried limit=undefined in my api call. This returned a Bad Request. It does not seem that there is any non-deprecated way to change this default limit at this time. Furthermore, the error message that I listed above does not describe the actual behavior of blueprint routes. Omitting limit does not default to MAX_SAFE_INTEGER. It defaults to 30.
@abatkins Unlimited records is simply not available for Find in blueprint routes to prevent quickly overloading the client's RAM, however, if you're looking to move a lot of data at once, you could technically set blueprints to a very large number like 10,000, but that many records at once also risks of overloading ram.
We recommend writing a script to page through a stable amount of records at a time such as 1,000 for more powerful client systems. The same principle applies to other frameworks as well.
That's fine. But the deprecation message indicates it does. If this is not the case that message should be changed as well as the documentation. In addition it is not clear how you would override the default limit that is set to anything other than 30. The defaultLimit parameter in blueprints does not appear to work anymore.
@abatkins Thanks, these are definitely valid points and I'll have them discussed with the team for the best plan of action to update these three areas. In the meantime, have you checked out using limit with parseBlueprintOptions to override default behavior for blueprint actions?
Yes, but this looks like an override not a default. If I set queryoptions.criteria.limit it would override whatever limit value I set, not simply provide a default when the limit is not specified.
Hi, @abatkins. Yes, defaultLimit is no longer supported by the most recent version of Sails (per this bit of the upgrade guide); parseBlueprintActions allows one to configure blueprint behavior in its stead.
That said, it seems like a custom action might serve you best. See the docs for more information on actions.
Edit: In case you do decide to use parseBlueprintOptions, here's a link to where it's called in the source code.