[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/IDBTransaction/objectStore [Back]  [Original]

IDBTransaction: objectStore() - Web API | MDN

MDN Web Docs

View in English Always switch to English

IDBTransaction: objectStore()

Baseline

20157

IDBTransaction objectStore()

IDBObjectStore IDBObjectStore

:

js
objectStore(name)

name

IDBObjectStore

NotFoundError DOMException

InvalidStateError DOMException

To-do Notifications ()

js
const note = document.getElementById("notifications");

// IDB  db 
let db;

// 
const DBOpenRequest = window.indexedDB.open("toDoList", 4);

DBOpenRequest.onsuccess = (event) => {
  note.innerHTML += "<li></li>";

  //  db 
  // 
  db = DBOpenRequest.result;

  // addData() 
  addData();
};

function addData() {
  // IDB 
  const newItem = [
    {
      taskTitle: "Walk dog",
      hours: 19,
      minutes: 30,
      day: 24,
      month: "December",
      year: 2013,
      notified: "no",
    },
  ];

  // 
  const transaction = db.transaction(["toDoList"], "readwrite");

  // 
  transaction.oncomplete = (event) => {
    note.innerHTML +=
      "<li>: </li>";
  };

  transaction.onerror = (event) => {
    note.innerHTML +=
      "<li></li>";
  };

  // 
  const objectStore = transaction.objectStore("toDoList");

  //  newItem 
  const objectStoreRequest = objectStore.add(newItem[0]);

  objectStoreRequest.onsuccess = (event) => {
    //  (
    // transaction.onsuccess )
    note.innerHTML += "<li></li>";
  };
}

Indexed Database API 3.0
# ref-for-dom-idbtransaction-objectstore


Web Proxy Viewer  |  New URL  |  Original Page