Closed ghost closed 6 years ago
Basically - features like autoincrement, unique etc. wont work when you are using bulkInsert. It simply insert data without checking any error or any other thing, that's why it is faster.
Check it out this stackoverflow query for more understanding - https://stackoverflow.com/questions/48831238/jsstore-bulkinsert-issue
Actually I have tried everything to make the doc more clear to understand for users. But seems like it is confusing. Any way I am working on making docs code public and publishing through GitHub, so that any one can update and docs can be made better.
Thanks
Erasing and then inserting the new data is a nice workaround. Anyway it seems that if the record already exists the behaviour is to simply ignore it.
Anyway it seems that if the record already exists the behaviour is to simply ignore it.
Can you exmplain more? I am not able to understand.
I mean that if I'm trying to add a record with the bulk insert and a record with the same ID exists, then the new record is not inserted and the old one is kept.
aha I see, that's a great finding. Thanks for sharing.
The bulkInsert function is really handy, but it's not clear how it treats data where a record with the same primary key already exists. I found in my experiments that the insertion is simply ignored (as it should in case of errors), and the old record is kept.
As I'm dealing with a synced database, I will try an erase pass first (I hope there is a way to delete multiple records with a single operation, just checking it now) and then a bulk load, or an update operation.
Maybe it would be good to document how the bulkInsert works and point to some IndexedDB tech docs.
p.s.: I hope I'm not spamming in the issues, just trying to help with what I find