STORE AN OBJECT USING THE INDEXEDDB API

You can store an object into an IndexedDB object store using the add() request method generated by a read-write transaction. Because all transactions run asynchronously, the request/event model allows your code to know when a transaction has completed.

Only an array or generic object can be stored, and not simple strings or numbers. Custom objects that are built with constructors will be destroyed, but their properties and values will survive.

 function addObject(object) { var transaction = db.transaction(objectStore, IDBTransaction. READ_WRITE); var store = transaction. objectStore(objectStore); var request = store.add(object); request.onsuccess = function(event) {...}; request.onerror = function(event) ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.