I created an IndexedDB databse named "A" by indexedDB.open method.
Now I want to modify the database name to "B", how can I do it?
I dont't want to create a new database with new name and copy all data from old database to new database.
I created an IndexedDB databse named "A" by indexedDB.open method.
Now I want to modify the database name to "B", how can I do it?
I dont't want to create a new database with new name and copy all data from old database to new database.
Share asked Nov 22, 2013 at 13:42 cuixipingcuixiping 25.5k9 gold badges87 silver badges94 bronze badges 2- why you need to change a database name? generally database name should not tied to data. – Kyaw Tun Commented Nov 22, 2013 at 15:10
- 1 Because I think the old name is ugly :) and maybe conflict with other apps in one site. – cuixiping Commented Nov 22, 2013 at 19:50
3 Answers
Reset to default 5From the main Documentation :
Every database has a name which identifies it within a specific origin.The name can be any string value, including the empty string, and stays constant for the lifetime of the database.
So, as it says, the name remains same for entire life.
It's a bit of a pain, but you could create a new database with the name you want, and copy everything from the old to the new. If you're using autoincrement IDs and you have cross-references by ID, you might need to generate maps of old-to-new id during transfers, and translate the references.
Renaming is supported in indexedDb v2.0. See https://hacks.mozilla/2016/10/whats-new-in-indexeddb-2-0/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744819738a4595543.html
评论列表(0条)