Alasql --- share with you


i’m happy to share this useful javascript tool to create local db and execute query on json data array

in a non vilual plugin add this:

this.getReactWebPackages = function() {
// Return dependencies that need to be included in the exported project’s package.json file.
// Each key is an npm package name that must be imported, and the value is the package version.
// Example:
// return { “somepackage”: “^1.2.3” }

return {“alasql”: “^0.4.11”}

this.writesCustomReactWebComponent = false;

this.getReactWebComponentName = function() {
// Preferred class name for this component.
// The exporter may still need to modify this (e.g. if there already is a component by this name),
// so in the actual export method below, we must use the className value provided as a parameter.
return “testnonvisual”;

this.getReactWebImports = function(exporter) {
var arr = [
{ varName : “{alasql}”, path : “alasql” }
return arr;

than in any javascript event or transformer function
you can use alasql so…

var alasql = require(‘alasql’);
var data = [{a:1,b:10}, {a:2,b:20}, {a:1,b:30}];
var res = alasql(‘SELECT a, SUM(b) AS b FROM ? GROUP BY a’,[data]);

i hope this will be usefulf for you
regards Paolo