rickdog
rickdog

Reputation: 758

indexedDB cross-browser not there yet?

Has anyone else found that IndexedDB stores created in Chrome aren't visible in Firefox and visa-versa?
I created some on google.com in each browser, but I can only see the ones there from the browser that created it. This is telling me that IndexedDB is not ready for prime-time

Upvotes: 0

Views: 704

Answers (2)

dgrogan
dgrogan

Reputation: 2720

Has anyone else found that IndexedDB stores created in Chrome aren't visible in Firefox and visa-versa?

Yes.

The behavior you seek is not what IndexedDB was designed for.

Upvotes: 1

hagrawal7777
hagrawal7777

Reputation: 14658

When you run the same URL again (in new tab or different browser) then what happens is that browser will see whether an IndexedDB already exists or not, and if it exists then it checks if the version of the new request and existing IndexedDB is same or not.

No existing IndexedDB:
If IndexedDB already doesn't exist then it will create a new one. Now in your case, since you are running it in different browser, for the first time IndexedDB will not be present and hence a new one will be created. *When new database is opened then onupgradeneeded is fired, and this is the place where new schema is created.* So, essentially all the data which you saw in Chrome will not be visible in Firefox and vice-versa. This is exactly what is happening in your case.

Existing IndexedDB but different version numbers:
If IndexedDB already exist, and the version number of new request is not same as existing datastore then both onsuccess and onupgradeneeded will be fired. This also means that you cannot see the old data.

Existing IndexedDB and same version numbers:
If IndexedDB already exist, and the version number of new request is same as existing datastore then only onsuccess is fired and onupgradeneeded will not be fired. This is as good as datastore is simply opened for access, and hence same data can be seen as earlier.

On a side note, sequence of firing of onsuccess and onupgradeneeded is - onupgradeneeded will be fired first (if fired) because this is the place where you create your scheme or data store, and then onsuccess event will be fired, where you can save the database handler for future operations like select, update etc.

Upvotes: 0

Related Questions