MongoDB - For each document
MongoDB - For each document
Runs a loop over each document returned by a MongoDB: Find multiple documents or MongoDB: Aggregation action. The actions inside the loop run once for every document, so each returned record can be processed individually.
Options
Document
Reference to the MongoDB: Find multiple documents or MongoDB: Aggregation action whose documents will be iterated.
Returns
Javascript code
js
actions["action-id"].currentDocument // document of the current iteration (Any)
actions["action-id"].currentDocumentIndex // index of the current document (Number)
Field selection
- currentDocument — document of the current loop iteration (Any)
- currentDocumentIndex — index of the current document, starting at
0(Number)
Rules and Conditions
- The Document field is required and must reference a MongoDB: Find multiple documents or MongoDB: Aggregation action.
- The actions inside the loop run once for every returned document.
- If the search returns no documents, the loop does not run.