Skip to content

Map

Converts all rows in the table to the return value of the given callback function.

1
myDataTable.Map(fn: (row: DataRow) => any):Array<any>

Converts all rows in the table to the return value of the given callback function.

1
myDataTable.Map(fn: (row: DataRow, i: number) => any):Array<any>

Parameters

(row: DataRow) => any fn
    A function to call for every data row.

Returns

An array containing the results of the callback function for each row. An array containing the results of the callback function for each row.

Remarks

If the callback function is null, an error is thrown.

Convert all rows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var table = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'Groups'
    }
});

var allRows = table.Map(function (row) {
    return {
        id : row.Id,
        name : row.Name
    };
});

// allRows is now [ {id:123, name:xxx}, {id:456, name:yyy}]

If the callback function is null, an error is thrown.