dbotransactionorders readonlyobjectStoreordersindexserviceid statusgetAllwindowserviceid 0; i only need the count consolelog it
To retrieve the count of the specified records, you can modify the code as follows:
const transaction = dbo.transaction(['orders'], 'readonly');
const objectStore = transaction.objectStore('orders');
const index = objectStore.index('serviceid, status');
index.getAll([window['serviceid'], 0]).onsuccess = function(event) {
const count = event.target.result.length;
console.log(count);
};
This code creates a transaction object, accesses the 'orders' object store, and then retrieves the specified records using the index. The onsuccess event handler returns the result, which is an array of records. By accessing the length property of the result array, you can get the count of the records and log it in the console
原文地址: https://www.cveoy.top/t/topic/hzCw 著作权归作者所有。请勿转载和采集!