In this tutorial we will learn how to do crud operation in jsstore.

Here is the working demo of below tutorial -


The simplest way to install jsstore is by using cdn. But since JsStore needs to be executed inside web worker for maximum performance and browsers does not allow cdn script for web worker. So the best way will be to download the script directly and use it.

You can download the script from github or from npm

For more about installation check out the installation doc.

Creating Database

JsStore follows SQL approach to create database - A database is consist of tables and a table is consist of columns.

Lets see how to create a database schema in JsStore.

As written in the code, you can define the constraints like autoincrement, datatype, default, notnull as you can do in SQL.

Now we need to create the database in indexeddb. So, lets create the database.

In the above code -
  • Line 1 - Storing the JsStore connection instance in a variable 'Connection'.
  • Line 2 - Declared a function initJsStore which will initiate the jsstore. Basically this will create database if it does not exist or open if it exist.
Note :- The connection object will be used to execute the further query. So we dont need to initiate it multiple times.

Inserting data

JsStore provides insert API for inserting data.

Read data

JsStore provides select API for reading data. Lets say I want to retrieve the record which contains Id 5.

You can also perform operations like- "IN", "LIKE", "BETWEEN", "LIMIT" etc.

Updating data

Lets say I want to update the product Quantity to 2000 which contains the item name - 'black'.

Delete data

Lets say I want to delete the product which contains the id - 10.

We hope - you have understood the above article. Now lets make something awesome.

* Check it out other articles -