2022.07.14 06:54 AM
This is a problem that I've come across a few times now and my javascript skills just aren't up to the task.
What code do I need to create a virtual datasource that takes in a table and outputs a distinct list from a column of that table?
I'm able to extract a column from a datasource using
function (source, callback) {
var result = {
"columns": [
"exchangeName",
],
"meta": {
"exchangeName": 11
},
"rows":[]
}
result.rows= _.map(source.rows, function(row) {
return {
"exchangeName": row.exchangeName,
}});
callback(result);
}
2022.07.14 08:12 AM
I have added an example below of how to get the distinct set of results (using _.uniqBy) . For more information on this function or any other useful functions please have a look at : https://lodash.com/docs/4.17.15
function (source, callback) {
var result = {
"columns": ["exchangeName"],
"meta": { "exchangeName": 11},
"rows": []
}
result.rows= _.uniqBy(source.rows,"exchangeName");
callback(result);
}
2022.07.14 08:12 AM
I have added an example below of how to get the distinct set of results (using _.uniqBy) . For more information on this function or any other useful functions please have a look at : https://lodash.com/docs/4.17.15
function (source, callback) {
var result = {
"columns": ["exchangeName"],
"meta": { "exchangeName": 11},
"rows": []
}
result.rows= _.uniqBy(source.rows,"exchangeName");
callback(result);
}
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.