EDIT: More details about what I have in my code so far:
/ so say this is my database (I’m not pulling it from the wix dataset yet - just working with this array as an example to make things simpler):/ var test = [{a:1, b:2, c:3}, {a:4, b:5, c:6}, {a:7, b:8, c:9}]
// I have managed to filter out a row - I can filter out the first row with: console.log(test.filter(x => x.c > 3));
// but like I said, I need to filter out a column, not a row.
/ I have also managed to ‘sum’ the objects in the array. But this doesn’t work - it doesn’t sum the numbers - it sums the objects and the below code will produce something like “[object Object][object Object][object Object]” / const total = (accumulator, currentValue) => accumulator + currentValue;
console.log(test.reduce(total));
Unfortunately this does not produce [{a:1, b:2}, {a:4, b:5}, {a:7, b:8}]. Instead it comes back with nothing i.e. it has removed the whole object because each has “c” in it.
Also I’m needing to filter out the columns I don’t need as I have 5 columns I don’t need and about 350 columns that I do need.
Also, regarding the reduce link, which mentions summing an object array, it has:
var initialValue = 0;
var sum = [{x: 1}, {x: 2}, {x: 3}].reduce(function (accumulator, currentValue) {
return accumulator + currentValue.x;
},initialValue)
console.log(sum)
This is the equivalent of summing a column in a database because it’s summing elements corresponding with ‘x’. I need to sum everything (not just one column). I don’t want to be stating every column I want included in the sum because like I said, I will have about 350 columns. I want to create a new array that omits about 5 columns and then sums the remaining elements.