tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

Reading the database data of an old web app version #313

Closed dannyalder88 closed 2 years ago

dannyalder88 commented 2 years ago

First sorry if this is posted in the wrong place, I've done an extensive search and cannot find an answer to my issue.

I am using _sembastweb for a web app and currently working on a new version (new Flutter project). I'm trying to read the old app database by opening a database with the exact same name on the new version. I was under the impression that as _sembastweb uses IndexedDb under the hood, the data would be available as long as the origin address is the same. This seems not to be the case.

Are my assumptions incorrect, or is something else needing to match in the projects. I've tested both on localhost and on a live site with the same domain and in both instances, _sembastweb does not find the old data and creates a new database or errors if I set mode to DatabaseMode.existing.

Is there any way of reading the old app data, or is this impossible to do? Thanks for your time and help!

alextekartik commented 2 years ago

Your assumptions are correct. It should work, as long as the domain name and database name is the same. Indeed it uses IndexedDB so you see the database in the chrome developer tools as well when you are on the domain. Hard to tell what is going wrong. The format has not changed so even an old version should work. I know it is hard to setup an example to reproduce the issue but if you have something to share, I can take a look.

dannyalder88 commented 2 years ago

After further digging, I managed to work out what was going on.

Running the app in Chrome from Android Studio opens the window with a new Chrome profile. This means that although the same project is persisting the data, it is not persistent across different projects. By copying and pasting the URL into my main Chrome window the data was available for both apps as expected.

Turns out it wasn't working on the live project as I wasn't awaiting the data to be written in the new app format correctly, which I noticed once I could see the old data was available. So this can be put down to poor code haha.

Thanks for your speedy reply and an awesome package!