IDBObjectStore

var dbopenrequest = window.indexeddb.open("todolist", 4); dbopenrequest.onsuccess = function(event){ note.innerhtml += '<li>database initialised</li>'; db = dbopenrequest.result; }; dbopenrequest.onupgradeened= function(event){ var db = event.target.result; db.onerror = function(event){ note.innerhtml +='<li>error loading database</li>'; }; var objectstore = db.createobjectstore("todolist", {keypath:"tasktitle"}); objectstore.createindex("hours","hours", {unique:false}); objectstore.createindex("minutes","minutes",{unique:false}); objectstore.createindex("day","day",{unique:false}); objectstore.createindex("month","month",{unique:false}); objectstore.createindex("year","year",{unique:false}); objectstore.createindex("notified","notified",{unique:false}); note.innerhtml +='<li>object store created</li>'; }; var newitem =[ {tasktitle: "walk cat", hours:19, minutes:30, day:24, month:'december', year:2018, notified: "no"} ]; var transaction = db.transaction(["todolist"], "readwrite"); transaction.oncomplete = function(event){ note.innerhtml +='<li> transaction opened for task addition</li>'; }; transaction.onerror = function(event){ note.innerhtml +='<li> transaction not opened due to error.duplicate items not allowed</li>'; }; var objectstore = transaction.objectstore("todolist"); var objectstorerequest = objectstore.add(newitem[0]); objectstorerequest.onsuccess = function(event){ noye.innerhtml +='<li>new item added to data base</li>'; }
The IDBObjectStore interface of the IndexedDB API represents an object store in a database. Records within an object store are sorted according to their keys. This sorting enables fast insertion, look-up, and ordered retrieval.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.