1

I`m using dexie wrapper library for indexedDB. I tried several ways to store objects in as Compound index in a table. Here is my table .

 db.version(1).stores({
        groupmap:"[g1+g2+g3],[g1+g2+g3+mdno],g1,g2,g3,active,mddate,mdno"
    });

Here is what I tried. But its not successful. and given error "DataError: Failed to execute 'only' on 'IDBKeyRange': The parameter is not a valid key. Error: Failed to execute 'only' on 'IDBKeyRange': The parameter is not a valid key"

 var g1Obj=new Object();
    g1Obj["id"]=1
    g1Obj["name"]="Breakfast"

    var g2Obj=new Object();
    g2Obj["id"]=1
    g2Obj["name"]="Burger"

    var g3Obj=new Object();
    g3Obj["id"]=1
    g3Obj["name"]="Chicken Burger"


             var obj = new Object();
                obj['g1']=g1Obj
                obj['g2']=g2Obj
                obj['g3']=g3Obj
                obj['mddate']=formatDateSecond4(new Date());
                obj['mdno']=formatDateSecond5(new Date());
                obj['active']=parseInt(1);

               db.transaction('rw',db.groupmap, function () {

                     db.groupmap.add(dataObj);
                     console.log ("[Group Map] Record saved to Local");

               }).catch(function (e) {
                      console.log ("[Group Map] Faild to save Record :"+e.message);

               });
4

1 回答 1

1

IE/Edge 不支持复合索引。你在其他浏览器上试过吗?您还可以尝试应用 IndexedDBShim 应该使复合索引在 IE/EDge 上工作。我自己没有测试过,但它声称支持它。

于 2017-06-09T10:58:10.340 回答