I am working with React 16.3.2, Redux 4 and Dexie 2.0.3.
when I am going to store data second time it throws this error message.
Error: ConstraintError: Key already exists in the object store.
return dispatch => {
db.table
.add(data)
.then (function(id){
console.log(id)
})
.catch (function (error) {
console.log("Error: " + error);
});
}
My Db schema:
const db = new Dexie('ReactReduxDexieJsCRUD');
db.version(1).stores({table:'++id,name,age,bloodGroup,donateBefore,weight' });
The first time it stores date well but after it gives the error.
put(data)
instead ofadd(data)
. – Silverfishadd
call. If you want to add data or update data if exist, try [dexie.org/docs/Table/Table.put()](put) instead ofadd
. – Genic