What is it?

jSQL is a partial yet robust SQL implementation with features specific to Javascript. jSQL is based on mySQL, but does not implement the entire standard, for example, JOIN statements are not yet possible with jSQL but it can run without a server and store Javascript Dates and Functions.

jSQL is completely hand written and has no dependencies.


Features
  • Can persist data to the user's hard drive from a browser.
  • Cross browser compatible & works on old browsers.
  • Allows you to define your own data/column types.
  • If you say J-S-Q-L really fast it sounds like "j-squirrel."
  • Exposes the "lower-level" interface for those that value a slight performance boost or just prefer a pure Javascript interface to an SQL interface.
Use cases
  • Manipulating sorting and querying (fairly) large datasets in the browser.
  • A more robust alternative to browser cookies.
  • Ideal for Cordova/Phonegap applications since it implements both WebSQL and IndexedDB.
  • Server caching (see the xhrCache plugin).
  • Saving state in browser or canvas based games.

Installation

Download the jSQL.js file from Github or use npm

npm install jsql-official

For use in a browser, just include the jSQL.js file in a <script> tag. In this case, you can use the CDN:

 https://gitcdn.xyz/repo/Pamblam/jSQL/master/jSQL.min.js 

For use in a Node environment, require it like so:

var jSQL = require("jSQL.js");

How does it work?

jSQL Layers
Under the hood, jSQL has 3 layers...
  • At the Lowest level, jSQL automatically chooses the best method of storage to save state and interacts directly with it. This layer exposes a persistence method, jSQL.commit(), which is called to serialize and store all data currently in the jSQL database on the user's hard drive. While the app is open and loaded in the browser, this data is serialized and stored within reach in the jSQL.tables object where the library is able to perform operations on it.

  • In the middle, a set of methods are used to build jSQLQuery objects which execute CRUD commands on the jSQL database and it's tables. (See: jSQL.createTable(), jSQL.select(), jSQL.insertInto(), jSQL.dropTable(), jSQL.update(), and jSQL.deleteFrom())

  • At the highest level, jSQL is an SQL engine (hence the name: Javascript Query Language) which understands a subset of MySQL passed to the jSQL.query() method, which parses a jSQL statement and uses the above methods to create jSQLQuery objects to perform operations on the database.

jSQL is written with flexibility, ease of use, and efficiency in mind. It supports prepared statements, column typing, and can store any kind of data you need it to, including functions and instances of custom objects. It's applications include caching server-sourced data, state persistence, data management and querying and more.


jSQL Devel

A handy tool if you're writing apps with jSQL.

  • Table wizard for creating tables
  • Generates raw SQL/jSQL and Javascript code
  • Customizable code settings (turn comments on/off, single line/multi line strings, etc)
  • Customizable interface makes development fun
  • Available as a standalone browser button or a jSQL plugin
  • [Read More]


Recent Updates

jSQL is actively updated and maintained. jSQL was last updated ... ago.