Add
Appends a new row to the table and returns the new row.
| myDataTable.Add(row: object):DataRow
|
Appends a new row to the table, calls the callback function on it, and returns the new row.
| myDataTable.Add(fn: (row: DataRow) => void):DataRow
|
Parameters
object row
An object containing the column values for the new row.
(row: DataRow) => void fn
A function instance to set row values.
Returns
A DataRow object representing the newly added row. A DataRow object representing the newly added row.
Create a new row from an object:
1
2
3
4
5
6
7
8
9
10
11
12
13 | var table = $Database.Empty({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
}
});
table.Add({
id : Script.NewId(),
name : 'Employee'
});
table.Save();
|
Create a new row with a mapper function:
1
2
3
4
5
6
7
8
9
10
11
12
13 | var table = $Database.Empty({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
}
});
table.Add(function () {
this.Id = id;
this.Name = 'Administrators-2';
});
table.Save();
|
Create a new row from an object:
1
2
3
4
5
6
7
8
9
10
11
12
13 | var table = $Database.Empty({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
}
});
table.Add({
id : Script.NewId(),
name : 'Employee'
});
table.Save();
|
Create a new row with a mapper function:
1
2
3
4
5
6
7
8
9
10
11
12
13 | var table = $Database.Empty({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
}
});
table.Add(function () {
this.Id = id;
this.Name = 'Administrators-2';
});
table.Save();
|
See Also