Wrapper for java.sql.Struct to emulate database structs, independently from the implementation.

1 Getting and setting attributes

Struct attributes are set on instance creation.

Copy
let struct = new Ax.sql.Struct('pie', 'jan',  10, 'feb',  20, 'march',  30, 'april',  40, 'may',  60, 'june',  60, 'july',  70, 'aug',  80, 'sept',  85, 'oct',  90, 'nov',  95, 'dec', 100);

Struct attributes can be retrieved with getAttributes(). As this function returns an Object[], we cannot simply print it. We have to iterate over its elements and print them.

Copy
let struct = new Ax.sql.Struct('vbar', 'jan',  10, 'feb',  20, 'march',  30, 'april',  40, 'may',  60, 'june',  60, 'july',  70, 'aug',  80, 'sept',  85, 'oct',  90, 'nov',  95, 'dec', 100);

for (elem of struct.getAttributes()) {
    console.log(elem);
}
vbar
jan
10
feb
20
march
30
april
40
may
60
june
60
july
70
aug
80
sept
85
oct
90
nov
95
dec
100

2 Plot generation

This data structure can be used to generate plots in DBStudio.

Copy
var rows = [
    new Ax.sql.Struct('pie', 'jan',  10, 'feb',  20, 'march',  30, 'april',  40, 'may',  60, 'june',  60, 'july',  70, 'aug',  80, 'sept',  85, 'oct',  90, 'nov',  95, 'dec', 100),
    new Ax.sql.Struct('vbar', 'jan',  10, 'feb',  20, 'march',  30, 'april',  40, 'may',  60, 'june',  60, 'july',  70, 'aug',  80, 'sept',  85, 'oct',  90, 'nov',  95, 'dec', 100)
];

return  new Ax.rs.Reader().build(rows, options =>  options.setColumnNames(["col_struct"]));