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
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. Lets create the database and grab the connection object.
The above code will create the database if does not exist or if it exist just open the database and store the connection.The connection object will be used to execute the query.
JsStore provides insert API for inserting 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.
Lets say I want to update the product Quantity to 2000 which contains the item name - 'black'.
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 -