Storing Data to the Object Store
Learn to add data to the object store.
To add data to a data store in IndexedDB, we need to follow these steps:
Open a database.
Create an object store.
Start a transaction.
Add the data to the object store using the
add()
method.
Till now, we know how to open a database and create an object store. Let’s see how to start a transaction and add data to the object store.
Start a transaction
To add data to a database, we need to create transactions. A transaction is a unit of work that makes changes to the database. To create a transaction, we should use the syntax below:
Get hands-on with 1400+ tech skills courses.