Google News
logo
JavaScript IndexedDB - Interview Questions
What are the key components of IndexedDB?
IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data.

The key components of IndexedDB include :

1. Database : This is the actual container for data storage. An IndexedDB database has a version and a set of object stores.

2. Object Stores : These are the IndexedDB equivalent of tables. Each database can have multiple object stores, and each object store can contain different types of data.

3. Keys : These are used to identify records in an object store. Every record in an object store must have a unique key. Keys can be simple types like integers, dates, and strings, or they can be arrays.

4. Indexes : Indexes are essentially object stores that store a key for every record in another object store. An index on a specific field in an object store allows efficient lookup of records based on that field, even if it's not the key.

5. Transactions : All interactions with data in IndexedDB happen in the context of a transaction. A transaction is a wrapper around an operation, or group of operations, with three possible modes: readonly, readwrite, and versionchange.

6. Versioning : IndexedDB uses a versioning model. Whenever the structure of the database changes (e.g., when object stores or indexes are created or removed), the version number of the database is increased.

7. Cursors : Cursors are used to iterate over multiple records in database. They offer a way to retrieve and update data in a specific sequence.

8. Requests : Almost every operation in IndexedDB is asynchronous and returns a request object. These requests are not the actual data but act as a placeholder for the data.

9. Queries : These are requests for data that meet certain criteria. Queries can retrieve data from both object stores and indexes.

10. Events : IndexedDB operations communicate success or failure by firing events at request objects. There are three types of events: success events, error events, and blocked events.
Advertisement