{
  "name": "Migrate large Hugging Face datasets to MongoDB with a looping subworkflow",
  "nodes": [
    {
      "id": "a22c634c-eb9b-4de7-be1e-40d9378f704b",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2128,
        672
      ]
    },
    {
      "id": "a711dee2-5337-4a4e-a653-3575ef5e72fc",
      "name": "setOffset",
      "type": "n8n-nodes-base.set",
      "position": [
        2352,
        672
      ]
    },
    {
      "id": "c8f6511a-b2e6-4a19-a5a8-639d2102466c",
      "name": "SubTrigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        560,
        768
      ]
    },
    {
      "id": "030000b4-48f3-490f-a2f8-ab86c077e451",
      "name": "HF_FetchRows",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        784,
        768
      ]
    },
    {
      "id": "857f2797-c61b-425c-b7a6-2dbad92b7337",
      "name": "Extract_Rows",
      "type": "n8n-nodes-base.set",
      "position": [
        1008,
        768
      ]
    },
    {
      "id": "514b4db6-79ae-4bcd-9b04-7be4a320f66b",
      "name": "HasRows?",
      "type": "n8n-nodes-base.if",
      "position": [
        1232,
        768
      ]
    },
    {
      "id": "80cb9377-07cd-441b-b61f-a137ae1a03ea",
      "name": "Row_Splitter",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1456,
        672
      ]
    },
    {
      "id": "2a7a5365-85c4-4ade-a76b-21bb5746060e",
      "name": "Transform_RemoveId_AddMeta",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        672
      ]
    },
    {
      "id": "e84f68de-6d2d-4f73-956d-58b42a6b8413",
      "name": "Mongo_InsertOrUpsert",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        1904,
        672
      ]
    },
    {
      "id": "8bf2959b-4d9f-4a09-aefc-1234ab2d1c02",
      "name": "Config_Start",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        208
      ]
    },
    {
      "id": "05dc3b69-7c33-40d7-ab39-2ccb20928ee6",
      "name": "Trigger_Manual",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        1344,
        224
      ]
    },
    {
      "id": "a19f7baf-6f71-4902-9f02-f6f522f4877c",
      "name": "ContinueLoop?",
      "type": "n8n-nodes-base.if",
      "position": [
        2208,
        208
      ]
    },
    {
      "id": "2f6dcaf1-76d7-48aa-8656-c814bd05ac9f",
      "name": "Stop",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2464,
        224
      ]
    },
    {
      "id": "57cdce0e-3f50-41bc-b191-f56f40601432",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -32
      ],
      "parameters": {
        "width": 720,
        "height": 464,
        "content": "## How it works:\n1- This workflow automates the migration of large datasets by fetching data in batches from the Hugging Face API. \n2- It begins with a configuration node where you define the dataset,"
      }
    },
    {
      "id": "a6d24010-70d8-4f33-a16d-654d691fa233",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        672
      ],
      "parameters": {
        "width": 624,
        "height": 304,
        "content": "Fetch & extract\nFetch rows from HF API, extract array, and split into items."
      }
    },
    {
      "id": "9ff85351-1953-45b9-a3da-63fee464dca1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        592
      ],
      "parameters": {
        "width": 1104,
        "height": 304,
        "content": "Transform & insert\nRemove HF _id, add metadata, then insert documents into MongoDB."
      }
    },
    {
      "id": "772be563-1834-4884-9338-fbcc7f6c3804",
      "name": "InsertBatch",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        1904,
        176
      ]
    },
    {
      "id": "73449288-7730-4f6f-9695-765750124336",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        112
      ],
      "parameters": {
        "width": 864,
        "height": 272,
        "content": "Loop & orchestration\nControl offset/length, call subworkflow per batch, repeat until no rows remain.\n"
      }
    },
    {
      "id": "c1740cac-c070-4c54-a3eb-ef7a56a2a65c",
      "name": "NoRows_Offset",
      "type": "n8n-nodes-base.set",
      "position": [
        1456,
        992
      ]
    },
    {
      "id": "47809a64-adef-44ff-a561-fb0f87b534c6",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        944
      ],
      "parameters": {
        "width": 224,
        "height": 304,
        "content": "### Set rows_count to zero"
      }
    }
  ],
  "connections": {
    "HasRows?": {
      "main": [
        [
          {
            "node": "Row_Splitter",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoRows_Offset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "setOffset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SubTrigger": {
      "main": [
        [
          {
            "node": "HF_FetchRows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "InsertBatch": {
      "main": [
        [
          {
            "node": "ContinueLoop?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config_Start": {
      "main": [
        [
          {
            "node": "InsertBatch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract_Rows": {
      "main": [
        [
          {
            "node": "HasRows?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HF_FetchRows": {
      "main": [
        [
          {
            "node": "Extract_Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Row_Splitter": {
      "main": [
        [
          {
            "node": "Transform_RemoveId_AddMeta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ContinueLoop?": {
      "main": [
        [
          {
            "node": "InsertBatch",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger_Manual": {
      "main": [
        [
          {
            "node": "Config_Start",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mongo_InsertOrUpsert": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform_RemoveId_AddMeta": {
      "main": [
        [
          {
            "node": "Mongo_InsertOrUpsert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}