不记录或检索数据

not recording or retrieving the data

出于某种原因,我无法检索 and/or 使用 IndexedDB 方法放置任何数据...是代码错误还是我遗漏了什么?

我已经放置了几个 console.log,并且我已经添加或尝试添加新值,但据说已经添加了它们(或者至少成功弹出了消息,但控制台日志中没有任何内容结果是...

let newDataLine = [{ name: name.value}];

let transaction = db.transaction( ["permit"], "readwrite");

transaction.oncomplete = function() {
statusText.textContent = 'Something was just added';
console.log('-------transaction.oncomplete----------')
console.log(objectStore);

// update the display of data to show the newly added item, by running displayData() again.
displayData();
};

transaction.onerror = function() {
status.textContent = 'Error reading/writing data from/into db error ' + transaction.error;
}

// call an object store that's already been added to the database
let objectStore = transaction.objectStore("permit");

let objectStoreRequest = objectStore.add(newDataLine[0]);

objectStoreRequest.onsuccess = function(event) {
statusText.textContent = 'New permit was just added';
console.log('-------objectStoreRequest.onsuccess----------')
console.log(objectStore);
}

完整代码位于 https://jsfiddle.net/m7nx9a3v/

我们的想法是将数据放置、检索和填充到 table... 提前致谢

function displayData() {
      let objectStore = db.transaction('permit').objectStore('permit');

      objectStore.openCursor().onsuccess = function(event) {
        var cursor = event.target.result;
        if (cursor) {
            dataLine.innerHTML+= '<tr><td>'+cursor.value.name+'</td><td class="buttons"></td></tr>';
          console.log(
            'Name for key ' + cursor.key + ' is ' + cursor.value.name
          );
          cursor.continue();
        } else {
          console.log('No more entries!');
        }
      };
    }

参考https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB