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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.