Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CREATE database if it does not exist should be optional #212

Open
brodycj opened this issue Mar 18, 2015 · 3 comments
Open

CREATE database if it does not exist should be optional #212

brodycj opened this issue Mar 18, 2015 · 3 comments

Comments

@brodycj
Copy link
Contributor

brodycj commented Mar 18, 2015

ADDITIONAL NOTE(S):

@brodycj
Copy link
Contributor Author

brodycj commented May 8, 2017

It would be ideal to keep the API as consistent as possible with the following:

I am thinking of adding an option such as createIfNecessary, createIfNotExist, or createIfNotPresent to let the app developer control this.

An alternative idea discussed in #401 is to add an openDatabase creation callback according to the Web SQL API. I think it would add extra, unneeded complexity but am happy to leave it open for discussion.

ADDITIONAL NOTE: the openDatabase creation callback would add extra complexity to higher level libraries such as Ionic-native & https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite, and it may cause problems with pre-populated database options discussed in storesafe/cordova-sqlite-storage-help#26 as well. NOT DESIRED.

@brodycj brodycj changed the title Make it optional to create a database file if it is not present CREATE database if it does not exist should be optional May 8, 2017
@brodycj
Copy link
Contributor Author

brodycj commented May 8, 2017

I would like to also address some discussion points in danielsogl/awesome-cordova-plugins#881:

From danielsogl/awesome-cordova-plugins#881 (comment) by @cocowalla:

The openDatabase method has been renamed to create, which despite the misleading name only actually creates a new database if the specified file doesn't already exist.

Agreed on my part.

From danielsogl/awesome-cordova-plugins#881 (comment) by @cocowalla:

  • Bit of a tangent, but both openDatabase and create don't quite describe what is happening - how about openOrCreate? (although I imagine you'll be reluctant to change it again so soon)

Nice idea but I would not favor it.

In general I think this plugin should have a single openDatabase entry point where the options may be passed down from higher level application code and libraries such as Ionic-native and pouchdb-adapter-cordova-sqlite.

As I said above my idea is to add an option such as createIfNecessary, createIfNotExist, or createIfNotPresent to let the app developer control this.

ADDITIONAL COMMENT: I would like to keep the API as consistent as possible with other SQLite APIs as discussed in the comment above.

I will probably need at least 1-2 months to clear my backlog before resolving this one.

@cocowalla
Copy link

@brodybits your alternative using an option sounds fine too, although its not immediately clear to me what the meaning of createIfNecessary and createIfNotPresent are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants