jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.31k stars 356 forks source link

Cannot creat objectStore #134

Closed rostgoat closed 4 years ago

rostgoat commented 4 years ago
const db = await openDB('db', 1, {
    upgrade(db) {
      db.createObjectStore('BobsYourUncle', { keyPath: 'id', autoIncrement: true });
    },
  });

I am expecting to see BobsYourUncleinside the objectStoreNames Array in browser but it's an empty list.. why?

Screenshot from 2019-10-25 12-31-26

if I attempt to add data to store

await db.add('user', { firstname: 'John', lastname: 'Doe', age: 33 });

I get

DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.

cuz store doesnt exist...

jakearchibald commented 4 years ago

https://output.jsbin.com/vipanum/ - here's a working example very similar to your code above.

I suspect you changed your upgrade callback but didn't change the version number of the database. upgrade only runs when the version number changes.

Please reopen this if you can create an example of the issue you're seeing.