
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
easyjsonsql
Advanced tools
Access JSON via sql like syntax. Easy to use JSON datasets from SQL query.
Access JSON via sql like syntax. This is my real timesaver when I am building reporting SPA application.
$npm install easyjsonsql
min,max,avg,count,sum
like, > , < ,>= ,<=
having use alias on min,max,avg,count and operater availables are >, < ,>= ,<=
let data=[ {name:'A C' ,age:30,location:'London',dob:'1930-01-25',info:{married:'Y','total_child':2}},
{name:'A C' ,age:35,location:'London',dob:'1930-01-26',info:{married:'N','total_child':3}},
{name:'A B' ,age:36,location:'London',dob:'1930-01-27',info:{married:'Y','total_child':4}},
{name:'A A' ,age:15,location:'Paris',dob:'1998-08-23',info:{married:'Y','total_child':2}},
{name:'A B' ,age:16,location:'Paris',dob:'1998-08-23',info:{married:'Y','total_child':2}},
{name:'A C' ,age:17,location:'Kathmandu',dob:'2000-03-23',info:{married:'Y','total_child':2}},
{name:'A A' ,age:15,location:'Paris',dob:'1998-07-01',info:{married:'Y','total_child':2}},
{name:'A B' ,age:16,location:'Paris',dob:'1998-07-26',info:{married:'N','total_child':0}},
{name:'A C' ,age:17,location:'Paris',dob:'1998-07-20',info:{married:'N','total_child':3}},
{name:'A A' ,age:20,location:'Paris',dob:'1998-07-24',info:{married:'Y','total_child':2}},
{name:'B A' ,age:15,location:'Kathmandu',dob:'1998-08-23',info:{married:'Y','total_child':2}},
{name:'B A' ,age:16,location:'Kathmandu',dob:'1998-08-23',info:{married:'N','total_child':0}},
{name:'B C' ,age:15,location:'Kathmandu',dob:'1998-08-23',info:{married:'N','total_child':2}},
];
let JSONSql=require('easyjsonsql');
let objUtil=new JSONSql();
On this sample we select the column and filter by using where and order by field [asc|desc]
let search_data=objUtil.select('name,location as ln,dob,info.married')
.from(data)
.where('info.married','=','Y')
.where('location','like','london')
.orderby('name asc')
.fetch();
console.log(search_data);
You will have output of :
[ { name: 'A B', location: 'London', dob: '1930-01-27', info: { married: 'Y', total_child: 4 } },
{ name: 'A C', location: 'London', dob: '1930-01-25', info: { married: 'Y', total_child: 2 } } ]
NOTE: Currently order by only detect integer and string. I am planning to order based date as well.
In this sample we have use count(),avg(),min(),max() aggregation method. Once we use aggregation method it will automatically group the result on selected field.
We have also used having filter on this sample. This will first create the result and then filter based on having filter.
and order the final result based on minimum age .
NOTE: Currently order by only detect integer and string. I am planning to order based date as well.
search_data=objUtil.select('name,count(name) as cnt_name,avg(age) as avg_age,min(age),max(age)')
.from(data)
.having('cnt_name','>','2')
.orderby('min_age desc')
.fetch();
console.log(search_data);
You will have output of :
[ { name: 'A C', age: 30, cnt_name: 4, avg_age: 24.75, min_age: 17, max_age: 35 },
{ name: 'A B', age: 36, cnt_name: 3, avg_age: 22.666666666666668, min_age: 16, max_age: 36 },
{ name: 'A A', age: 15, cnt_name: 3, avg_age: 16.666666666666668, min_age: 15, max_age: 20 }
]
NOTE: Currently order by only detect integer and string. I am planning to order based date as well.
FAQs
Access JSON via sql like syntax. Easy to use JSON datasets from SQL query.
The npm package easyjsonsql receives a total of 4 weekly downloads. As such, easyjsonsql popularity was classified as not popular.
We found that easyjsonsql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.