HTML and CSS Reference
In-Depth Information
IndexedDB was being talked about when the first edition of this
book was published, but there were no implementations at the
time. Today there are only vendor-prefixed implementations at
this point, but I suspect it won't be long before most, if not all,
browsers support IndexedDB.
IndexedDB is a document object store. It's like a database, but it
doesn't come with all SQL and relational database gubbins.
In IndexedDB, you create a new database and give it a name
and a version so you can reopen it later. Then you create an
object store, which is very much like a filing cabinet with indices
that allow you to quickly skim through and find the right docu-
ment. Once the store is ready, you can store any kind of object
against the index you're filing with. It doesn't matter what it
contains, and it doesn't have to have the same properties as the
other objects either. This is where SQL often becomes a prob-
lem. You have a huge table, you need to add one teeny, incon-
spicuous new column, and so begins the pain. You have none of
those woes with IndexedDB.
Using IndexedDB before it's out of beta
IndexedDB may still be in the vendor-prefix stage by the time you read this chapter.
If that's the case, you can still use IndexedDB, but you will need to either create forks in your code to han-
dle the different naming convention, or just copy the vendor-prefixed version into the real name:
function importIndexedDB(prefix) {
var indexedDB = window[prefix + 'IndexedDB'],
IDBTransaction = window[prefix + 'IDBTransaction'];
if (indexedDB !== undefined) {
window.indexedDB = indexedDB;
if (IDBTransaction !== undefined) {
window.IDBTransaction = IDBTransaction;
// try all the vendor prefixes
'moz webkit o ms'.split(' ').forEach(function (vendor) {
Search WWH ::

Custom Search