HTML and CSS Reference
In-Depth Information
Figure 11-6. Listing the captured pieces
In this chapter you took a crash course in Indexed DB. Through a fairly simple application, you utilized most
of the capabilities of this new technology. Probably the biggest challenge is to get used to the asynchronous
processing. The sample application provides lots of examples of nesting successive calls through the onsuccess
event handler. Some of the key concepts to remember include:
onupgradeneeded event
handler when the database is opened. Use the version to force an upgrade, if necessary.
Create the database and create its structure by responding to the
Objects in a store must have a unique key, which can either be defined by a key path for
in-line keys, or a key generator for out-of-line keys. You can also supply the key manually
when the object is added but that's not generally a practical solution.
All data access (read and write) must be done through a transaction object. When
creating the transaction you must specify the scope, which is the list of object stores that it
will use as well as the type of access that is required.
You can add one or more indices to an object store. Each index maps a key path in the
object to the object's key.
Use a cursor to process multiple objects in an object store. The objects that are selected
can be filtered by specifying a key range.
Add an object to the object store and update it later.
Retrieve an object from an object store.
Delete an object from an object store by specifying the object's key.
getKey() method of the index.
Obtain the key for an object by using the
put() method of an object store to add or update an object. The put() method
requires both the objects and the key. This will add the object if the specified key is not
Use the
There is a lot that you can do with a local database like Indexed DB. Because the data is on the client, you
avoid roundtrips to the server.
Search WWH ::

Custom Search