wahlborn
6 years agoNew Contributor II
Assistance requested creating pipeline for SQL query-->mapper-->text file
My goal is to execute a SQL query, return data, and format it so that it is accepted by a custom app we run here. So far, I have extracted the necessary data and formatted it using a mapper. The ma...
- 6 years ago
I think you can use the
.map()
method on Array objects to do this since the callback will be passed the current index into the array. The following expression does this:$lines.map((elem, index) => { lineNumber: index + 1, ...elem })
The
.map()
method will iterate over each element in the$lines
array and execute the given callback function (the part that starts with(elem, index) =>
. The callback function creates a new object with the newlineNumber
property and then uses the spread operator (...elem
) to add in the properties from the original array element.Here’s a pipeline that demonstrates this:
Community7085_2020_03_16.slp (3.6 KB)