storesafe / cordova-sqlite-evcore-extbuild-free

Cordova sqlite plugin with Android performance enhancements for PhoneGap Build, GPL v3 or commercial license options
Other
24 stars 13 forks source link

Question about close DataBase #53

Open Elyft opened 4 years ago

Elyft commented 4 years ago

Hello how can i check if a transaction is in progress before to close the database,because on my code i can have multiple insertion at the same moment

brodycj commented 4 years ago

The plugin JavaScript should wait for all transactions to finish before actually closing a database.

Elyft commented 4 years ago

ok so if i don't use the closeDb function explicitly when the transactions will be over the plugin will close the Database...am i right?

brodycj commented 4 years ago

If you open a database, the plugin and underlying SQLite implementation keeps the resources open so that you can read and write to the database until you actually close it.

Can you give me an idea why you wanted to close the database in the first place?

It should be safe to just leave the database open. According to https://www.sqlite.org/lockingv3.html, SQLite should be ACID Wikipedia: ACID which means that it should never lose any data from changes that have been committed. I have also made some updates with extra durable build settings (see https://github.com/xpbrew/cordova-sqlite-storage/issues/736) to be extra safe.

Elyft commented 4 years ago

I closed the database after each request because I thought that was the right thing to do. Thank you for opening my eyes to this. I won't shut up anymore.