{
  "name": "database_include",
  "nodes": [
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "nombre_normalizado"
            },
            {
              "fieldToAggregate": "Principio activo"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        384,
        -32
      ],
      "id": "08241427-f37c-444d-afa6-20b0e02f409c",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "Execution"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -64,
        -32
      ],
      "id": "742f6352-b873-481a-81e0-b1f4851cbac5",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "content": "## Extracci\u00f3n de nombre y datos normalizados\nHace un includes y devuelve todos los datos con los que hace match. ",
        "height": 320,
        "width": 1000
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -144,
        -128
      ],
      "id": "a4bb44b9-dbbb-4adc-95d2-8e7a6cc39110",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "jsCode": "const input = $('When Executed by Another Workflow').first().json.Execution ?? \"__no__matches__\"\nconst nombres = $input.first().json.nombre_normalizado;\nconst principios = $input.first().json['Principio activo'];\n\nfunction get_nombres (input, nombres) {\n  let nombre_normalizado = [];\n  for (const nombre of nombres) {\n    if (input != null && nombre.includes(input)) {\n      nombre_normalizado.push(nombre) \n    }\n  }\n  if ( nombre_normalizado.length > 0){\n    return [...new Set(nombre_normalizado)];\n  }\n  else {\n    return [\"no matches found\"]\n  }\n}\n\nfunction get_principios(input, principios) {\n  let principio_activo = [];\n  for (const principio of principios) {\n    if (input != null && principio.toLowerCase().includes(input)) {\n      principio_activo.push(principio)\n    }\n  }\n  if (principio_activo.length > 0) {\n    return [...new Set(principio_activo)];\n  }\n  else {\n    return [\"no matches found\"]\n  }\n}\n\nreturn {nombres_normalizados: get_nombres(input, nombres), principio_activo: get_principios(input, principios)}\n\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        592,
        -32
      ],
      "id": "c255df8c-9232-4611-837a-154424eff5e1",
      "name": "Code1"
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "dummy_table_products",
        "returnAll": true
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        192,
        -32
      ],
      "id": "0bad35a8-9346-4da4-86e3-ef11925ef9da",
      "name": "Get many rows",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get many rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many rows": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "be4deedc-a01f-4c56-bb40-1ce7862f8c32",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "cKdVGvO88p5I1Szd",
  "tags": []
}