Scenario: Results of a query returns 4 operations with the exact same results

I’m trying to understand scenarios and modules like crazy. But I don’t get why at a certain point, multiple operations are run with one module, always returning the same results, which then leads to duplicates in the next module that is based on the former module’s bundles.

After a webhook trigger, (1) I’m looking for the latest item in a Notion database, which returns the desired one bundle. The next module (2) is looking for database items in a second database that have a relationship to the result from (1). This is working flawlessly, and correct results are found in one operation (in my case, four items). Now, in step (3) I am then looking for items in a third database that have a relationship to (1). Although - in my example - only two items have to be found, and indeed are found in the first operation, the module runs four times = operations, always returning the two bundles over and over again. I set the limit for this bundle to either nothing or 1.000, a value it would never reach in practice, and from my understanding, the module should run once, find all database items that match and then proceed to the next step. Did I get something wrong about modules?

Also, bonus question: step (4) is creating new items in database 3. Due to step (3) running even after step (4) has started, newly created items from step (4) in database 3 are then included in the results, thus found in a parallel operation of step (3), so it loops and creates items until the end of time. How can I let each module finish first and then proceed to the next one?

Hi there.

There is one general rule: The number of operations performed by a module is determined by the number of bundles in the previous module/s output/s. So, if the previous step returned 4 bundles, the next step will be processed 4 times. If you want to prevent this from happening, you would need to aggregate the results somehow. This should also answer your “bonus” question. You need to aggregate the results before continuing to the next step.

Hope this helps.

Cheers

1 Like