ijmacd-query
SQL for JSON objects/APIs
Last updated a year ago by ijmacd .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ijmacd-query 
SYNC missed versions from official npm registry.

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('http://dummy.restapiexample.com/api/v1/employees') (You might need to "allow unsecure scripts" because restapiexample.com doesn't support https)

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(DATEADD(DAY, value))) AS nasa WHERE media_type = 'image' SELECT nasa.*

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.

Current Tags

  • 1.6.3                                ...           latest (a year ago)

17 Versions

  • 1.6.3                                ...           a year ago
  • 1.6.2                                ...           a year ago
  • 1.6.1                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.1                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |