• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jSQL is the "official" Javascript Query Language - A database written in Javascript for use in a browser or Node.

jSQL Logo

jSQL (Official) - Version 3.3.19 - Now available without a prescription!

npm version Build Status Inline docs Coverage Status


jSQL is a state and data management tool as well as a robust SQL engine for both Node and the browser. For complete documentation, please see the jSQL Wiki. For plugins, live demos and other information see the official website.

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.


Quick Start

jSQL is implemented in a single JavaScript file. You only need either the jSQL.js file or the minified jSQL.min.js file. Feel free to download them directly or use npm:

npm install jsql-official

If you're running jSQL in a browser, include it in a script tag.

<script src='jSQL.js'></script>

Or use the one hosted on the github.io site:

http://pamblam.github.io/jSQL/scripts/jSQL.min.js

If you're running jSQL in Node, require the jSQL module.

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

Create a table

When the database has loaded into memory, you'll want to make sure you have a table to work with. Any database operations that are to be made immediately when the app loads should be called from within the jSQL.load() callback.

jSQL.load(function(){
    var sql = "create table if not exists users (name varchar(25), age int)";
    jSQL.query(sql).execute();
});

Insert into table

At some point, you might want to put some data in that table.

jSQL.query("insert into users ('bob', 34)").execute();

Prefer prepared statements? Just replace values with question marks and pass the values to the execute method in an array.

jSQL.query("insert into users (?, ?)").execute(['bob', 34]);

Select from table

Once you've got the data in there, you're probably going to want to get it back out.

var users = jSQL.query("select * from users where name like '%ob'").execute().fetchAll("ASSOC");

Persisting changes in the browser

When you've made changes or additions to the database, call jSQL.commit() to commit your changes.

For more information and to read about other update, delete and other operations, see the jSQL Wiki.


Documentation & Examples

jSQL is fully documented in the jSQL Wiki, which even includes more simple usage examples. You may also refer to the package's tests for more complete and complex examples. There is also a live demo available on the official website.


Browser Support

Works in basically all browsers. jSQL degrades gracefully because it falls back on cookies for persistence if localStorage, IndexedDB and WebSQL are not available.

While jSQL will work in basically all browsers, these ones are preferred:

FireFox Android Safari Chrome Samsung Blackberry IE Opera Edge
2+ 2.1+ 3.1+ 4+ 4+ 7+ 8+ 11.5+ 12+

It's Official

In the same way Fedex is Federal.


Thanks to


🇺🇸

More Repositories

1

mysql-import

Import .sql files using NodeJS
JavaScript
35
star
2

Tamper-Data-for-FF-Quantum

Tamper Data for FF Quantum
JavaScript
18
star
3

protodate

Better Javascript Dates.
JavaScript
15
star
4

snek

stupid snek
JavaScript
14
star
5

CalendarJS

Create a responsive monthly calendar with events using vanilla Javascript.
JavaScript
13
star
6

Crawler

A PHP flexible web crawler that can login into a website.
PHP
12
star
7

iLoveLAMP

iLL is a suite of LAMP tools with a dynamic, responsive interface; error logging, resource management, etc. It provides an interface for many of the things you might do via SSH.
PHP
12
star
8

WhoDownvotedMe.js

A userscript that aims to identify users who downvote your answers on Stack Overflow.
JavaScript
8
star
9

browser-mirror

mirror actions on a web page remotely
JavaScript
7
star
10

placeSearch.js

Thin wrapper for Google Places implemented as a jQuery plugin.
JavaScript
5
star
11

fileUpload

A jQuery plugin for creating file input buttons.
JavaScript
4
star
12

biden-soundboard

Joe Biden Soundboard (Hacktoberfest 2021)
JavaScript
4
star
13

rage-quit

Rage quit Reddit
JavaScript
4
star
14

animate.js

Not another JS Animation library. Really.
HTML
4
star
15

tab-composer

just a weekend project - composing guitar tabs
JavaScript
2
star
16

Methodus

A Math Library inspired by Project Euler
JavaScript
2
star
17

RotateBG

Rotate and cross fade background images with this simple jQuery plugin.
JavaScript
2
star
18

tinyJWT

The smallest, simplest possible JSON Web Token PHP implementaion.
PHP
1
star
19

phpDataTables

Wrapper for Datatables that allows for easy client-side configuration
TypeScript
1
star
20

Go-Life

Conway's Game of Life
HTML
1
star
21

Official-Jeff-Goldblum-Firefox-Plugin

The Official Jeff Goldblum Firefox Extention
1
star
22

jsql-devel

JavaScript
1
star
23

ez-drag-n-drop

Simple plugin to allow users to drag and drop to rearrange elements in the DOM.
JavaScript
1
star
24

remoteTime

A jQuery plugin for creating textual time and/or date clocks for any place in the world.
JavaScript
1
star