GithubHelp home page GithubHelp logo

Comments (12)

jepiqueau avatar jepiqueau commented on May 19, 2024

@srbala there is no plan for this. PouchDB is a document database not SQL. The problem associated with PWA or Web browsers app is that no permanent storage is available. Before to answer, i look at pouchDB and try without success to create an app in typescript with Ionic5 and Angular9 and using pouchdb-adapter-cordova-sqlite and cordova-plugin-sqlite-2 (Could not import pouchdb) to create a service. Is your choice of pouchDB was related to have a PWA app synchronizing with a CouchDB server database or was it just to have an sql equivalent database for PWA or Web apps. In that case we may be looking to IndexedDB which is also not an sql driven database. So not sure that all SQLite statements could be implemented ? Can you tell me more about your concern

from sqlite.

srbala avatar srbala commented on May 19, 2024

Looking into the possibility of single ORM layer library (lets say capacitor-db-wrapper as CDW) which can work browser and app, detects and adopts based on availability or device type. This way app development has the calls CDW, CDW takes care of rest.

https://pouchdb.com/adapters.html
https://www.techiediaries.com/ionic-sqlite-pouchdb/

https://github.com/google/lovefield seems to alternate for SQL like statements and can be a bridge

from sqlite.

srbala avatar srbala commented on May 19, 2024

Having single code base for Mobile app vs PWA, when it comes to storage, it seems to be complicated.

from sqlite.

fernandocode avatar fernandocode commented on May 19, 2024

I don't know, but it looks like what you (@srbala) want is what the plugin was already doing (https://github.com/jepiqueau/capacitor-data-storage-sqlite), even before this sql plugin was created, maybe what you are requesting is the opposite of what I requested some time ago (jepiqueau/capacitor-data-storage-sqlite#11).

I didn't deep into your request, so I may be completely wrong

from sqlite.

jepiqueau avatar jepiqueau commented on May 19, 2024

@srbala is the answer given by @fernandocode is good enough for what you are looking for ? As you close the issue i assume yes. Thanks anyway for looking at both plugins

from sqlite.

srbala avatar srbala commented on May 19, 2024

@jepiqueau Thanks for checking

I think might have to do some more research and experiments.

Mobile app development is fairly new world for me, trying to PWA in parallel. My experience in the past are mainly enterprise application development, usually use ORM layer (like typeorm) to mask the difference between databases and environments.

I am looking for a library (or ready to contribute to built one) for mobile and PWA, which can hide the complexity underneth and provide consistant API for development.

from sqlite.

fernandocode avatar fernandocode commented on May 19, 2024

As I saw that you mentioned the typeorm (I found it very interesting), if you go to a project where sql is needed, I use in my projects ionic-database-builder, which in its base uses database-builder, currently I haven’t published the configuration for use with capacitor (open an issue there, which I add, because the provider isn’t complete yet), the purpose of not being an orm in fact, is just a way of abstracting much of the complexity of the sql commands, and not having to create string commands, which leads to many errors.

from sqlite.

jpike88 avatar jpike88 commented on May 19, 2024

Please reopen this issue.

My company has been using enterprise-grade hybrid + web + pouchDB + cordova-sqlite-storage for many years now. I've been looking at ways to transition us off Cordova, but this is a major blocking problem.

your choice of pouchDB was related to have a PWA app synchronizing with a CouchDB server database or was it just to have an sql equivalent database for PWA or Web apps. In that case we may be looking to IndexedDB which is also not an sql driven database

To answer this, it's purely to act as a safe, permanent storage, nothing more fancy than that. I would not trust indexedDB on iOS device at all, it's primarily to ensure data permanence and no tricks being done by the WKWebKit module. We have high value clients and need to use the safest ways of data storage we can.

Here's the implementation of it, you may want to model off that.
https://github.com/storesafe/cordova-sqlite-storage/blob/dev/www/SQLitePlugin.js

from sqlite.

jpike88 avatar jpike88 commented on May 19, 2024

Another big reason I forgot is that sqlite allows limits for indexeddb to be cancelled out, the way we use pouchDB means that often we may breach 100s of megabytes, even up to a 1GB of storage.

Using this as an adapter will allow us to make the step fully out of Cordova space.

Why not use SQL instead? We have a lot of 'templates' that consist of JSON documents with many flags and other things on them.

Using the PouchDB map/reduce method, I can easily define a view that can interrogate each document in a bucket to give me specific results. It's a far more efficient and cleaner code than just iterating over an SQL table, and the performance profile is simple to understand.

from sqlite.

jpike88 avatar jpike88 commented on May 19, 2024

I should have added another couple of reasons:

  • PouchDB enables sane cross-platform local storage of things like access tokens, user preferences, any other localized data that a web SPA would worry about. That means I'm not having to implement SQL for mobile, and some other layer or adapter for web to store and interrogate the exact same data.
  • Why not use a local preferences or something? Aside from the fact that I can't enumerate collections of data on it, @capacitor/preferences recommends not using native local prefs for fast and frequent access of local data.
  • IndexedDB is poorly supported and has a history on safari of being unreliable https://twitter.com/feross/status/1404568122158313474, I don't the risk of my users to be randomly logged out of a mobile app.

I'm also asking the cordova-sqlite-storage if they're able to make themselves capacitor-native, which would solve my problem. I could probably contribute to them to achieve that, can't be too difficult. But I like your project better, it's cleaner and capacitor first. If a pouchDB adapter can be looked at seriously that would be great, maybe I could write but I'd need some tips.

from sqlite.

jepiqueau avatar jepiqueau commented on May 19, 2024

@jpike88 are you talking about a web app or native app? In Native the plugin stores the databases in the device as pure sqlite db. In web i use sql.js which use the database in memory and store it with localeforage in indexdb. There is also a method to store it in the filesystem if you wish. It working offline. If you want to connect it to a remote server there are mthods to import from and export to json object. I will not go for pouchdb. If you want to have this you must developp a pouchDb capacitor plugin on its own. Hope this clarify

from sqlite.

jpike88 avatar jpike88 commented on May 19, 2024

Fair enough... a shame because I can't just dump pouchdb anyway. I need to look at bringing that other plugin across. Do you know how hard that might be?

from sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.