https://github.com/101samovar/js-web-...
Hi, in this video we will create a simple use case for the web-SQL.
The web-SQL is a client-side relational database.
This database can be used to store data in offline mode.
So let’s create a site.
Suppose we need to store offline the price list for gems and available amount of gems.
We will save the data in two separate tables.
First of all we need to open the database. We use the openDatabase method with params: short name, version, display name and the maximum size in bytes.
If the database does not exist it will be created.
After the database has been created we use the transaction method of the database object.
The transaction method has a callback param in which we can make queries to the database with executeSql method.
A query to create a table.
A query to insert values to the table.
And a query to select data from the table.
So let’s create a table “gems” with columns: name and price.
And a table “store” with columns: gem and amount.
Then let’s insert values into tables “gems” and “store”.
To get the data from the database we use another transaction and another executeSql method.
So let’s select for each gem name the total sum of gem price multiplied by amount of gems.
Here you are.
Thank you for watching to the end.
Subscribe to our channel and you will find more JS-videos.
На этой странице сайта вы можете посмотреть видео онлайн Web Sql javascript длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Samovar tutorials 04 Декабрь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 13,645 раз и оно понравилось 379 зрителям. Приятного просмотра!