storesafe / cordova-sqlite-storage-help

Help forum for Cordova sqlite plugin projects
2 stars 1 forks source link

Prepopulated database documentation fix [options] #26

Open brodycj opened 7 years ago

brodycj commented 7 years ago

From discussion in https://github.com/driftyco/ionic-native/issues/881 there seems to be a bit of confusion about prepopulated databases. In general I can think of the following options:

The createFromLocation option discussed in option 1 will only work in cordova-sqlite-ext (and certain other evplus and FUTURE TBD cordova-sqlite-evcore-extbuild-free). The other options will work in all sqlite plugin versions.

In case of options 3 and 4 the proper database location is platform dependent. I will raise an issue on cordova-sqlite-storage to add a function to get the platform dependent database directory path.

I would personally favor options 5, 6 and 7 since they would work the cleanest. The downside is that there are issues with large batches that are solved in cordova-sqlite-evcore and cordova-sqlite-evplus plugin versions, with GPL or commercial license options.

ADDITIONAL NOTES:

I can think of 2 major pre-populated database scenarios:

In general it would be much better if litehelpers/Cordova-sqlite-storage#212 (CREATE database if it does not exist should be optional) would be resolved in the near future.

brodycj commented 7 years ago

I would also favor the following added option (just discovered and added above):

cocowalla commented 7 years ago

I will raise an issue on cordova-sqlite-storage to add a function to get the platform dependent database directory path

+1 for this

I would personally favor options 5 and 6 since they would work the cleanest

In general, I'd agree, and this feels like the most 'natural' and obvious solution for the majority of use cases. But there are times (as the discussion in driftyco/ionic-native#881 ) when using a pre-populated database makes sense. cordova-sqlite-storage seems to already support this scenario (your options 3 and 4), bit I gather this is somewhat 'unofficial'?

brodycj commented 7 years ago

I would personally favor options 5 and 6

Now options 5/6/7 (I just discovered option 7).

But there are times (as the discussion in driftyco/ionic-native#881 ) when using a pre-populated database makes sense.

Agreed.

cordova-sqlite-storage seems to already support this scenario (your options 3 and 4), bit I gather this is somewhat 'unofficial'?

Not anymore, thanks to the discussion in driftyco/ionic-native#881. This will be documented when I make the next cordova-sqlite-storage release.

@cocowalla your point does make sense and I will update the documentation of cordova-sqlite-storage to reflect this (along with some other items in litehelpers/Cordova-sqlite-help#26).

From https://github.com/driftyco/ionic-native/issues/881#issuecomment-299974967:

Woah as the primary author and maintainer I find that statement confusing! The cordova-sqlite-storage version does NOT implicitly support pre-populated databases (using the createFromLocation option).

@brodybits I find that statement confusing! :) I'm using this method successfully [...]

Got it. So far I had only supported option 1 which does need cordova-sqlite-ext. The discussion in driftyco/ionic-native#881 basically expanded the definition which I am now happy to accept and support in the documentation.

To address a couple more points in https://github.com/driftyco/ionic-native/issues/881#issuecomment-299974967:

  • The reason for downloading populated databases (rather than downloading the data and inserting it into a new database created by the client), is that the databases I'm working with are rather large. It's far more efficient for my use case to download a ready-made database

Agreed, and this is the original reason why I had supported option 1 in cordova-sqlite-ext.

  • Is there some reason you would expect this not to work?

The samples in https://github.com/driftyco/ionic-native/issues/881 do not address the Windows platform.

Due to this discussion I am now thinking to put cordova-sqlite-ext into a "legacy maintenance" (deprecated) status and make a pure JavaScript replacement for option 1 (using cordova-plugin-file).