我正在为我的应用程序使用索引数据库
我有一个表格产品,我在其中添加了两个索引
 var product = evt.currentTarget.result.createObjectStore("product", { keyPath: product_id" });
 product.createIndex("productIndex", "product_id", { unique: true });
 product.createIndex("barCodeIndex", "ean_product", { unique: false });
在我的代码中,首先我搜索 product id ,如果结果为 null ,我搜索 bar code 。问题是我编写的代码在 Chrome 和 IE 10 中运行良好,但在 FF 中无法运行。请建议。
在我搜索条形码的其他部分中,行“var keyBarcode =barcodeSearch.index("barCodeIndex");” 抛出异常 “操作失败,因为找不到请求的数据库对象。例如,对象存储不存在但正在打开。”
   var searchKey = IDBKeyRange.only(productId);
    var productSearch = localDatabase.db.transaction("product").objectStore("product");
    var key = productSearch.index("productIndex");
  key.get(searchKey).onsuccess = function (evt) {
        var productSearchResult = evt.target.result;
        if (productSearchResult != null) {
         //some logic
        } else {
            //search on bar code
            var barcode = $("#txtProductCode").val().trim();
            var barcodeKey = IDBKeyRange.only(barcode);
            var barcodeSearch = localDatabase.db.transaction("product").objectStore("product");
                var keyBarcode = barcodeSearch.index("barCodeIndex");
                keyBarcode.get(barcodeKey).onsuccess = function(event) {
                    var barcodeSearchResult = event.target.result;
                    if (barcodeSearchResult != null) {
                        //some logic                     
                    } 
                };
        }
    };