Skip to content

AddData

Appends a new row to the specified target table and returns the inserted row as a DataRow object.

1
$Database.AddData(schema: string, table: string, input: object):DataRow

Adds a new row to the specified target table in the target data store and returns the inserted row as an object.

1
$Database.AddData(store: string, schema: string, table: string, input: object):DataRow

Parameters

string schema
    The name of the target schema.

string table
    The name of the target table.

object input
    A JavaScript object containing the column values for the new row.

string store
    The name or ID of the target data store. This overload requires it.

Returns

A DataRow object representing the newly inserted row.

Remarks

The row is saved immediately. Properties are matched to columns by name, case-insensitively; properties without a matching column are ignored.

Examples

Insert a row

1
2
3
4
5
6
var row = $Database.AddData('Sales', 'Orders', {
    Id : $Xml.Evaluate('Id'),
    Customer : $Xml.Evaluate('Customer/Id'),
    OrderDate : $Calendar.Today,
    Status : 'New'
});

Insert a row into a specific data store

1
2
3
4
$Database.AddData('Archive', 'Sales', 'Orders', {
    Id : $Xml.Evaluate('Id'),
    Status : 'Archived'
});

See Also