Reading the Data from the Object Store

Learn to read data stored in the object store.

We'll cover the following

Follow the steps below to get the stored data from the object store:

  1. Open the database.

  2. Create a transaction to access the object store.

  3. Use the get() method to get the data from the object store.

We know how to open database connections and create transactions. Let’s learn about fetching the data from the object store.

Get the data

Once we have the object store, we can get the data by calling the get() method on the object store.

The get() method takes the key of the data as a parameter and returns an IDBRequest object. If the get operation is successful, the success event is fired for the request object, and the data is present in the result property of the request object. If there’s no data for the given key, then we get undefined inside the result property.

Example

Get hands-on with 1400+ tech skills courses.