ngx-indexed-db icon indicating copy to clipboard operation
ngx-indexed-db copied to clipboard

Support for "out-of-line" keys?

Open BruceWilcox opened this issue 1 year ago • 6 comments

Do you support "out-of-line" keys?

If so, can you give an example of how to set the 'storeConfig' value and 'storeSchema' values?

My data already has an unique "id" field.

I am getting error: DOMException: Failed to execute 'add' on 'IDBObjectStore': The object store uses in-line keys and the key parameter was provided.

Thank you.

BruceWilcox avatar Oct 21 '23 21:10 BruceWilcox

Hi @BruceWilcox, Can you share your storeConfig and a single data that you want a store? It seems to me that out-line-key not supported.

Thansk.

aparzi avatar Oct 22 '23 19:10 aparzi

Hi @BruceWilcox, if you already id for your entities should be configure your store in this mode: Screenshot 2023-10-23 alle 12 53 27

Set id or your custom key for storeConfig with autoincrement false, and call method add, put and etc... without passing key.

aparzi avatar Oct 23 '23 10:10 aparzi

Please see my project at https://github.com/iTipsDev/demo-angular-ngx-indexed-db

It works ok if records added one at a time. But fails when using bulk option. I need the better performance of the bulk option.

error

BruceWilcox avatar Oct 24 '23 00:10 BruceWilcox

Hi @BruceWilcox, I tried your example but bulkAdd works fine for me. Are you sure your db is empty? Because if you do the normal add first and then the bulkAdd this won't work

aparzi avatar Oct 24 '23 08:10 aparzi

I am still trying to get the same results are you are. Is "if you do the normal add first and then the bulkAdd this won't work" a documented limitation?

BruceWilcox avatar Oct 25 '23 01:10 BruceWilcox

If you call the add method you wrote, it iteratively inserts each element of your json. BulkAdd does the same thing in a massive way, consequently if the db is not empty you are trying to insert duplicate elements (since you are working with the id of each element of the same json).

aparzi avatar Oct 25 '23 07:10 aparzi