Zum Hauptinhalt springen

For@1

Der Node For@1 ermöglicht es, von 0 bis zu einer angegebenen Anzahl von Iterationen zu iterieren und für jede Iteration eine Sub-Transformations-Pipeline auszuführen.

Der Node erzeugt ein Array von Ausgaben, eine pro Iteration.

Adapter-Voraussetzungen​

  • Allgemeine Verfügbarkeit: Alle Adapter unterstützen diesen Node-Typ.

Node-Konfiguration​

Zu den Feldern path, targetPath, targetValueWriteMode und targetValueKind siehe Überblick.

EigenschaftTypErforderlichBeschreibung
countintegerneinStatische Anzahl von Iterationen. Wird verwendet, wenn countPath nicht gesetzt ist.
countPathstringneinJSON-Pfad zur dynamischen Auflösung der Iterationsanzahl aus dem Datenkontext. Hat Vorrang vor count, wenn gesetzt.
indexTargetPathstringneinPfad, unter dem der aktuelle Iterationsindex (0-basiert) gespeichert wird.
maxDegreeOfParallelismintegerneinMaximaler Grad an Parallelität. 0 = Anzahl der Prozessoren (Standard), -1 = unbegrenzt, positiv = explizites Limit.
transformationsarrayjaSub-Pipeline-Nodes, die für jede Iteration ausgeführt werden.
hinweis

Entweder count oder countPath sollte angegeben werden. Wenn beide gesetzt sind, hat countPath Vorrang.

Beispiel mit statischer Anzahl​

transformations:
- type: For@1
count: 4 # Number of iterations
targetPath: customers # Path where the data should be stored in the payload (will be an array)
transformations: # Sub pipeline that will be executed for each iteration
- type: Simulation@1
simulations:
- targetPath: $.customer.firstName
simulatorKey: Person.FirstName
- targetPath: $.customer.lastName
simulatorKey: Person.LastName
- targetPath: $.customer.street
simulatorKey: Address.StreetName

Beispiel mit dynamischer Anzahl​

Wenn die Iterationsanzahl aus dem Datenkontext kommen soll (z. B. aus einem HTTP-Request-Body), verwenden Sie countPath:

transformations:
- type: FromHttpRequest@1
method: POST
path: /create-items
- type: For@1
countPath: $.count # Reads count from the HTTP request body
indexTargetPath: $.index
targetPath: $.results
transformations:
- type: FormatString@1
format: "Item-{$.index}"
targetPath: $.name