Loop through MySQL Results

Hi there,

Am using n8n to migrate the data from MySQL to MongoDB. MySQL query returns more than 100+ records and I want to check each records is exists in MongoDB, if not exists I want to insert into MongoDB. For this I have designed workflow as follows

But the workflow is checking and inserting only the first record. Can some one help me to insert all the records into mongoDB.

Thanks in Advance.

You need to apply a SplitInBatches node after Mysql node.

Then, you will recover record in Mongo.

If record doesn’t exist, set node and insert into Mongo. Later send to another IF node to check if there are more records to check.

If it exists, send to the IF node to check if there are more rows to check.

If no more rows, finish flow.