balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

.eachBatch() does not accept batch size argument #6877

Open leonatoieiri opened 5 years ago

leonatoieiri commented 5 years ago

According to the documentation eachBatch() have an optional argument to customize the batch size, however this is not working at the moment.

I think this is happening because this feature is only available on Waterline 0.14, and the current version available on npm is 0.13.6

This is the error message:

UsageError: Missing or invalid iteratee function for .stream(). Details: For eachBatchFn, instead of a function, got: 100

Sample code:

await Subscriber.stream({ country: 'pt' }).eachBatch(100, async records => { console.log('Got ' + records.length + ' records.'); });

Link to the documentation

Node version: v12.10.0 Sails version (sails): sails@1.2.3 ORM hook version (sails-hook-orm): sails-hook-orm@2.1.1 Sockets hook version (sails-hook-sockets): sails-hook-sockets@2.0.0 DB adapter & version (e.g. sails-mysql@5.55.5): sails-mysql@1.0.1


sailsbot commented 5 years ago

@leonatoieiri 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.

kesgri commented 4 years ago

Same here. Docs say there is another way: .meta({batchSize: 100}). for eachRecord. Tried using it with eachBatch (hoped it would work)... I need to go through 50M records and in batches of 30 it's plain slow.

johnabrams7 commented 4 years ago

@leonatoieiri Thanks for taking the time to explore this. To further understand the issue, can you provide us a minimal Sails repo that reproduces the error? I think you might be right about the Waterline version causing this limitation; if that's the case, we'll update the docs until that version is released.

sereisoglu commented 3 years ago

Hi, I have the same problem. Any updates?

eashaw commented 3 years ago

Hi @leonatoieiri and @sereisoglu, we discovered that sails-generate was using an old version of sails-hook-orm, this has been fixed. To fix this issue in your existing app, you'll need to update sails-hook-orm to v3.0.0, which includes Waterline 0.14.

sereisoglu commented 3 years ago

@eashaw It's works. Thank you.