JSqlDb is a database engine that natively speaks json and javascript. It does not store tables and rows, like an sql database, but instead it stores javascript objects and primitives. For example:

And unlike a nosql doument store, there is no document boundary, everything is directly accessible:

because it does not store just json, it stores javascript objects, including executable functions, and references to other objects

It can use these references and connections to model graph data, but it can also easily store tabular data using either object or array collections


Querying data

All queries target the database referred to by a database handle (db in this case). Getting the database handle depends on the client driver and will be covered later.
For simple queries, simple object access can be used, similar to accessing data from normal javascript objects.

The query language also defines various query functions that can be called on database objects, for example:


Like normal javascript object, JSqlDb objects supports prototypal inheritance.

A benefit of this is that all fields that are at default values do not take up any storage space in the database.


Similarly functions are also supported, and could be seen as analogue to stored procedures in other database systems – but with the power and ease of javascript.

One final example

Next: JSqldb In Practice