Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

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

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

Arguments

(row: DataRow) => any fn

...

(row: DataRow, i: number) => any fn
Function to call for every data row.

Remarks

If callback is null, error is thrown.

Example

Convert all rows

...

languagejs

...

row.

...

Remarks

If callback is null, error is thrown.

Example

Convert all rows

Code Block
languagejs
var table = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'Groups'
    }
});

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

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

Examples

...

Code Block
languagejs
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}]

...

Code Block
languagejs
var table = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'Groups'
    }
});

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

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