Write values into tables
exports.main = function (config, context) {
var dslPeers = config.getTableByOid("1.2.2.19");
var dslBackup = dslPeers.createNewRow();
dslBackup.setByOid("1", "BACKUP");
dslBackup.setByOid("3", "9999");
dslBackup.setByOid("5", "DHCPOE");
dslBackup.setByOid("15", "local");
dslBackup.setByOid("17", "off");
dslPeers.addOrMerge(dslBackup);
};
<table>.createNewRow()
creates a new row object in the script's memory.<table>.addOrMerge()
will add a new row if no matching index column in the given table exists, in the device's config. <table>.addOrMerge()
will merge the data if a row with a matching index column already exists, in the device's config. This means, overwriting existing rows is handled by this step.
Read values from tables
exports.main = function (config, context) {
var dslPeers = config.getTableByOid("1.2.2.19");
var dslBackup = dslPeers.getRowBySingleIndex("BACKUP");
dslBackup.setByOid("3", "8888");
dslPeers.addOrMerge(dslBackup);
};
- To get multiple matches you can use
table.getRowsByAliases(Map<alias, value>)
.
For example:
var rows = dslPeers.getRowsByOids({"5": "9999"});
Delete values from tables
exports.main = function (config, context) {
var table1_2_2_19 = config.getTableByOid("1.2.2.19");
var table_1_2_2_19_row_2 = table1_2_2_19.createNewRow();
table_1_2_2_19_row_2.setByOid(1, "INTERNET-DEFAULT");
table_1_2_2_19_row_2.delete();
};