Add Index to Pre-Existing ObjectStore In IndexedDB Using Javascript

后端 未结 2 549
不思量自难忘°
不思量自难忘° 2021-01-04 18:09

I have seen multiple JavaScript examples of using createIndex to define an ObjectStore index directly after the ObjectStore has been created like this:

2条回答
  •  走了就别回头了
    2021-01-04 18:58

    You do it during onupgradeneeded, which should be the same place you are making the object store in the first place. In there, you can do whatever appropriate action is needed to upgrade it, such as creating a new index. Here is an example.

提交回复
热议问题