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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sql-engine

v0.0.2

Published

A SQL query engine built on levelup/leveldb - uses level-queryengine

Readme

sql-engine

A technology proof-of-concept of using MySQL and SQL to query a levelup/leveldb database.

Implemented as part of a hack project for campjs 2013.

Pull requests encouraged!

This will eventually become a plugin for the level-queryengine pluggable query engine system.

Quick start

To play around with this, git clone and npm install and start the example server and specify a port to listen to:

$ node server.js 3307

The example Server adds the following non-relational JSON documents to the local leveldb:

[
  { "name": "Bob", "num": 42, "awesome": "goodbye", "x": 99 },

  { "name": "Jane", "num": 43, "awesome": "blah",
    "car": { "make": "Toyota", "model": "Camry" } },

  { "name": "Peter", "num": 88, "awesome": "true",
    "car": { "make": "Toyota", "model": "Corolla" } }
]

Connect to the levelup MySQL server (authentication and database selection not currently implemented)

$ mysql -P 3308 --protocol=tcp

Execute some queries against the test 'users' table:

mysql> select * from users;
+-------+------+---------+------+----------+-----------+
| name  | num  | awesome | x    | car.make | car.model |
+-------+------+---------+------+----------+-----------+
| Bob   |   42 | goodbye |   99 | NULL     | NULL      |
| Jane  |   43 | blah    | NULL | Toyota   | Camry     |
| Peter |   88 | true    | NULL | Toyota   | Corolla   |
+-------+------+---------+------+----------+-----------+
3 rows in set (0.00 sec)

mysql> select name, num from users where car.make = 'Toyota';
+-------+------+
| name  | num  |
+-------+------+
|  Jane |   43 |
| Peter |   88 |
+-------+------+
2 rows in set (0.00 sec)

How it works

  • sql-engine uses the awesome mysql2 library to do the MySQL proxying to look like a MySQL server protocol speaking server.
  • sql-engine parses the SQL using simpleSqlParser into an AST.
  • the SQL AST is then parsed into the mongodb query language and ran using jsonquery-engine against the levelup/leveldb instance.

Notes

This is highly experimental, and needs a lot more work to support the full suite of SQL operations.

  • Currently only AND and OR are implemented for SQL queries.
  • Currently only equality is implemented for SQL where clauses (eg. colA = colB)
  • the 'FROM' statemenet will query a levelup "sublevel" by that name.
  • No database authentication is implemented.
  • No joins are currently implemented. I plan to use foreign-key and/or level-join to implement this.
  • No sorting is implemented. I plan to use sort-stream to do that.
  • simpleSqlParser also parses INSERT, DELETE and UPDATE statements, but these haven't been implemented.