only-cliches / Nano-SQL

Universal database layer for the client, server & mobile devices. It's like Lego for databases.
https://nanosql.io
MIT License
782 stars 49 forks source link

listDatabases function not pulling existing databases from indexedDb #197

Open kuhlaid opened 4 years ago

kuhlaid commented 4 years ago

Which version are you using? 2.3.7

Describe the bug I am able to create a 'PERM' database with data using nSQL().createDatabase() and then am able to immediately lists the databases using nSQL().listDatabases(), HOWEVER if I reload my app and only try listing the databases again I get nothing even though the local databases still exist in my browser. I looked in the nano code within core/lib/index.js and noticed that nanoSQL.prototype.connect() is the only place that sets the 'this.dbs' object (which is used to list the databases in nSQL().listDatabases().

nSQL().listDatabases() needs to be able to list databases that exist. I am also not able to retrieve rows from existing databases if I do not 'recreate' the databases each time I reload my app, even though the data is there there from the last time I ran my app. Again, the core code needs the 'this.dbs' object to somehow create connects to the existing databases using something similar to what is created for each database in 'nanoSQL.prototype.connect()'.

Just from a brief review of your code I'm not sure how you would list existing indexedDb databases unless you are tracking the database keys/names in localStorage in order to call the indexedDb.open() function.