npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ijmacd-query

v1.7.0

Published

SQL for JSON objects/APIs

Downloads

32

Readme

JS SQL Query

Build Status

A simple (read: toy) SQL implementation made from scratch in pure JS.

Examples

Basic SELECT from a Demo table.

FROM Test SELECT n,n2,n3

Basic WHERE clause on a Demo table. SELECT defaults to SELECT *.

FROM Test WHERE n > 2

Full CROSS JOIN on Demo tables.

FROM Test, Test

JOIN with predicate.

FROM Test AS a, Test AS b ON a.n < b.n

There are even some built-in table valued functions.

FROM RANGE(3,15, 2)

LOAD is also a table valued function to load data from an arbritrary url.

FROM LOAD('https://api.github.com/users/IJMacD/repos'), Owner

FROM LOAD('http://www.reddit.com/r/javascript.json'), data.children AS c, c.data AS d

FROM LOAD('https://dummy.restapiexample.com/api/v1/employees'), data

You can use expressions in table valued functions.

FROM RANGE(-7,0), LOAD('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=' || DATE(DATE_ADD(CURRENT_DATE(), value, DAY))) AS nasa WHERE media_type = 'image' SELECT nasa.* [⯈](https://ijmacd.github.io/query/#q=FROM%20RANGE(-7%2C0)%2C%20LOAD('https%3A%2F%2Fapi.nasa.gov%2Fplanetary%2Fapod%3Fapi_key%3DDEMO_KEY%26date%3D'%20%7C%7C%20DATE(DATE_ADD(CURRENT_DATE()%2C%20value%2C%20DAY)))%20AS%20nasa%20WHERE%20media_type%20%3D%20'image'%20SELECT%20nasa.*)

Going deeper...

FROM (FROM LOAD('https://xkcd.com/info.0.json') SELECT num), RANGE(num,num - 10), LOAD('https://xkcd.com/'||value||'/info.0.json') (won't work in browser due to XKCD CORS issues but works on server)

CTEs are supported.

WITH cte AS (FROM Test_2 WHERE c > 'd') FROM Test, cte ON CHAR(n+97) = c

As are window functions.

FROM Test SELECT n, n2, RANK() OVER(ORDER BY n2)

FROM Test SELECT n, SUM(n) OVER(PARTITION BY n2)

FROM Test SELECT n, SUM(n) OVER(ORDER BY n ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

Check out the tests for more examples of supported features.