Search code examples
next.jsindexeddbdexie

Next.js / Dexie: Failed to execute 'add' on 'IDBObjectStore': Evalu…he object store's key path did not yield a value


When attempting to save using Dexie i encounter the error below, this error strictly occurs in production with no errors occurring when i attempt to save data. Any help much appreciated!

the error:

"Failed to execute 'add' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
 DataError: Failed to execute 'add' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value."

db setup

db.version(1).stores({
  people: '++id, name',  
});

Add

const newId = await db.people.add({
                name: userName,
                blocks,
                lists,
});

Solution

  • Check in the console for a warning. It might be that the database was created using an alternate primary key (for example 'id' without '++') and then you've changed the primary key to '++id' after that.

    If that is the case, you can delete the database from devtools --> application --> IndexedDB and reload the app.