To log the count of the result, you can modify the code as follows:

const transaction = dbo.transaction(['orders'], 'readonly');
const objectStore = transaction.objectStore('orders');
const index = objectStore.index('serviceid, status');
const request = index.getAll([window['serviceid'], 0]);

request.onsuccess = function(event) {
  const result = event.target.result;
  const count = result.length;
  console.log(count);
};

This code creates a transaction, retrieves the object store and index, and executes a 'getAll' query with the specified criteria. The 'onsuccess' event handler is used to retrieve the result and log the count of the result array.

Count Indexed Database Entries with Specific Service ID and Status

原文地址: https://www.cveoy.top/t/topic/o2pC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录