Indexed DB API Flashcards

1
Q

What is IndexedDB?

A

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. While DOM Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does IndexedDB lets you store and retrieve objects that are indexed?

A

With a key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What kind of objects can be stored in IndexedDB?

A

Any objects supported by the structured clone algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the steps in IndexedDB usage?

A

You need to specify the database schema, open a connection to your database, and then retrieve and update data within a series of transactions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why are operations performed using IndexedDB are done asynchronously?

A

So as not to block applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where is client side data stored?

A

On your local disk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you get access to a database?

A

Call open() on the indexedDB attribute of a window object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the open() method return?

A

An IDBRequest object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Asynchronous operations communicate to the calling application by firing events on what kind of objects?

A

On IDBRequest objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Connecting to a database: describe IDBEnvironment.

A

Provides access to IndexedDB functionality. It is implemented by the window and worker objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Connecting to a database: describe IDBFactory.

A

Provides access to a database. This is the interface implemented by the global object indexedDB and is therefore the entry point for the API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Connecting to a database: describe IDBOpenDBRequest.

A

Represents a request to open a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Connecting to a database: describe IDBDatabase.

A

Represents a connection to a database. It’s the only way to get a transaction on the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Retrieving and modifying data: describe IDBTransaction.

A

Represents a transaction. You create a transaction on a database, specify the scope (such as which object stores you want to access), and determine the kind of access (read only or readwrite) that you want.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Retrieving and modifying data: describe

IDBRequest.

A

Generic interface that handles database requests and provides access to results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Retrieving and modifying data: describe IDBObjectStore.

A

Represents an object store that allows access to a set of data in an IndexedDB database, looked up via primary key.

17
Q

Retrieving and modifying data: describe IDBIndex.

A

Also allows access to a subset of data in an IndexedDB database, but uses an index to retrieve the record(s) rather than the primary key. This is sometimes faster than using IDBObjectStore.

18
Q

Retrieving and modifying data: describe IDBCursor.

A

Iterates over object stores and indexes.

19
Q

Retrieving and modifying data: describe IDBCursorWithValue.

A

Iterates over object stores and indexes and returns the cursor’s current value.

20
Q

Retrieving and modifying data: describe IDBKeyRange.

A

Defines a key range that can be used to retrieve data from a database in a certain range.

21
Q

Retrieving and modifying data: describe IDBLocaleAwareKeyRange.

A

Defines a key range that can be used to retrieve data from a database in a certain range, sorted according to the rules of the locale specified for a certain index (see createIndex()’s optionalParameters.).

22
Q

Custom event interfaces: describe IDBVersionChangeEvent.

A

The IDBVersionChangeEvent interface indicates that the version of the database has changed, as the result of an IDBOpenDBRequest.onupgradeneeded event handler function.

23
Q

What is IndexedDB, in short?

A

A low-level API for storing client-side data.

24
Q

Describe Object Store.

A

An object store is the primary storage mechanism for storing data in a database.

Each database has a set of object stores. The set of object stores can be changed, but can only be changed using a “versionchange” transaction, i.e. in response to a upgradeneeded event. When a new database is created it doesn’t contain any object stores.

The object store has a list of records which hold the data stored in the object store. Each record consists of a key and a value. The list is sorted according to key in ascending order. There can never be multiple records in a given object store with the same key.

Every object store has a name. The name is unique within the database to which it belongs. Every object store also optionally has a key generator and an optional key path. If the object store has a key path it is said to use in-line keys. Otherwise it is said to use out-of-line keys.

25
Q

Describe the createObjectStore() method.

A

The createObjectStore() method creates and returns a new object store with the given name in the connected database. Note that this method must only be called from within a “versionchange” transaction.

If this database is not running a “versionchange” transaction, or if this function is called on a IDBDatabase object other than that transaction’s connection, the implementation must throw a DOMException of type InvalidStateError. If the “versionchange” transaction is not active, the implementation must throw a DOMException of type TransactionInactiveError. If an object store with the name name already exists in this database, the implementation must throw a DOMException of type ConstraintError.

If the optionalParameters argument is specified and has a keyPath property which is not undefined or null, then set keyPath to the value of this property. If keyPath is not a valid key path, the implementation must throw a DOMException of type SyntaxError.

If the optionalParameters argument is specified, and autoIncrement is set to true, then set autoIncrement to true. If autoIncrement is true and keyPath is an empty DOMString or any sequence, the implementation must throw a DOMException of type InvalidAccessError.