0

Is it posible to keep alive several connections when one of them makes a version change?

I'm trying to have one connection for each ObjectStore, creating the ObjectStore when opening the connection, so that each connection only does transactions to its ObjectStore.

I understand how to add new ObjectStores and changing version (see How to create multiple object stores in IndexedDB, or Can you ever alter the structure of an indexedDB database after it has been opened in firefox?), and that every connection has to close while changing version.

However, I'm not sure if the connections reconnect automatically, or there is some event listening the completion of the upgrade, or if I have to do it by hand.

I'm afraid that I will have to check before any transaction that the db is opened, and if it is closed, open it. Nevertheless, I wonder if there is a better approach. Also, I'm not asking for code, just some guidelines, references or ideas.

Thanks in advance.

Community
  • 1
  • 1
jmmut
  • 884
  • 9
  • 19

1 Answers1

1

Yes, all connections has same version.

You cannot alter version after a connection is opened. (old spec can, but not anymore).

If you lose a connection, it will not automatically connected. In fact, a connection will not lose, unless you close it.

If you open a connection with newer version while other connection exists, existing connections will be notified via onversionchange event - and existing connections MUST close the connection so that a new connection is proceed.

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83