0

Being new on the forum (well found a lot of answers already) hereby my first question:

When filling an indexedDB with data (using dixie) I want to refer dynamically to the different stores. For now i solved it by using cases:

switch (i){
            case 1: db.Reactor_1.bulkPut(result); break;
            case 2: db.Reactor_2.bulkPut(result); break;
            case 3: db.Reactor_3.bulkPut(result); break;
            case 4: db.Reactor_4.bulkPut(result); break;
            case 5: db.Reactor_5.bulkPut(result); break;
            case 6: db.Reactor_6.bulkPut(result); break;
        }
        i++;

i have tried different notations to concatenate the number into the call:

db.'Reactor_'+i.bulkPut(result);
db.Reactor_{i}.bulkPut(result);
eval("'db.Reactor_'+i+'.bulkPut(result);');

and a few more but none work. How can this be achieved?

My question is being labeled as already answered. That particular answer I had found before and tried all suggestions but none work...

KVan
  • 1
  • 2
  • Have you tried using bracket notation from the duplicate? `var reactor = 'Reactor_'+i; db[reactor].bulkPut(result)` – haldo Oct 20 '19 at 22:57
  • Maybe I should have been more complete. Yes I have also checked the one you propose. i tried all proposals of the one that was marked as answered before (even before my post) but nothing worked. It seems to be something with the library. I found an alternative writing in the library: db.table("Reactor_"+reactor).bulkPut(result); this works fine. BTW sorry for the late reply due to business travel. – KVan Oct 28 '19 at 20:27

0 Answers0