OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Indexeddb - records are added successfully, except index is missing data

  • Thread starter Thread starter dman
  • Start date Start date
D

dman

Guest
Using indexeddb and idb promise library.

I have this objectstore that I create called storeMappings along with the index inUse. I then populate the store with some records.

Everything works as it should except for one issue. The index inUse does not show any data. Any ideas why?

Code:
const _addStoreMappings = async (db) => {
  const mappings = db.createObjectStore('storeMappings', {                            
    keyPath: 'id', 
    autoIncrement: true,                                                              
  });                                                                                 
  
  await mappings.createIndex('inUse', 'inUse');                                       
  
  await mappings.add({ store: `store0`, name: `foo store`, inUse: true });            
  
  Array.fromAsync({ length: 14 }, (_, i) => (
    mappings.add({ store: `store${++i}`, name: '', inUse: false })                    
  ));                                                                                 
};

enter image description here

enter image description here

<p>Using indexeddb and idb promise library.</p>
<p>I have this objectstore that I create called <code>storeMappings</code> along with the index <code>inUse</code>. I then populate the store with some records.</p>
<p>Everything works as it should except for one issue. The index <code>inUse</code> does not show any data. Any ideas why?</p>
<pre class="lang-js prettyprint-override"><code>const _addStoreMappings = async (db) => {
const mappings = db.createObjectStore('storeMappings', {
keyPath: 'id',
autoIncrement: true,
});

await mappings.createIndex('inUse', 'inUse');

await mappings.add({ store: `store0`, name: `foo store`, inUse: true });

Array.fromAsync({ length: 14 }, (_, i) => (
mappings.add({ store: `store${++i}`, name: '', inUse: false })
));
};
</code></pre>
<p><a href="https://i.sstatic.net/BH6T0ifz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BH6T0ifz.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/65TqzMbB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/65TqzMbB.png" alt="enter image description here" /></a></p>
 

Latest posts

A
Replies
0
Views
1
AgencyAnalytics
A
S
Replies
0
Views
1
Stacker Media
S
C
Replies
0
Views
1
CC.Talent
C
Top