question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Add forAll for cursor queries

See original GitHub issue

Do you want to request a feature or report a bug? Feature

Feature Description

For cursor queries (that return the data in batches) currently there is a method forEach which is used to loop over each document returned from the query not each batch. it would be nice to loop over each batch so you can perform a bulk action on each batch.

Use Case

You want to send an email to all users currently in your system obviously you will fetch the whole user collection in batches. But it’s not very efficient to send each user an email one at a time that wouldn’t be very cost effective plus any mail service has a limit on the max number of bulk emails that could be sent (1000 for example). So the ideal situation would be to fetch the users in batches of 1000 and for each batch perform a bulk action of sending an email to all those users.

I can make the PR myself but I will wait for the issue approval

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vkarpov15commented, Feb 2, 2021

I think a batchSize option to eachAsync() would work if you’re willing to put in a PR 👍

0reactions
khaledosama999commented, Feb 5, 2021

@vkarpov15 Done I don’t know exactly how you manage features but the feature branch was based on branch 6.0 and the PR is on branch 6.0 also I didn’t want to come near the master branch as I’m assuming this is the branch used for the latest mongoose version

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bulk data processing with BULK COLLECT and FORALL in PL ...
In this article, I will cover the two most important of these features, BULK COLLECT and FORALL: BULK COLLECT: These are SELECT statements ......
Read more >
Oracle PL/SQL BULK COLLECT: FORALL Example - Guru99
This BULK COLLECT can be used in 'SELECT' statement to populate the records in bulk or in fetching the cursor in bulk.
Read more >
Collections, Cursors, Bulk Binds and FORALL
CURSOR c IS SELECT * FROM all_objects;. BEGIN OPEN c; LOOP FETCH c BULK COLLECT INTO l_data LIMIT p_array_size;. FORALL i IN 1..l_data.COUNT...
Read more >
BULK COLLECT & FORALL vs. CURSOR & FOR LOOP
The major difference between the INSERT and the FORALL statements is that the INSERT statement gets execute for every single row from your ......
Read more >
Bulk Binds (BULK COLLECT & FORALL) and Record ...
The SQL%BULK_ROWCOUNT cursor attribute gives granular information about the rows affected by each iteration of the FORALL statement. Every row in the driving ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found