1 Reply Latest reply on Nov 7, 2019 11:59 PM by User555046-Oracle

    Offline Persistence Toolkit - SQLite

    Luiz B



      I am experimenting using Offline Persistence Toolkit with SQLite adapter, and I have a question regarding it.


      I have configured OPT and registered my scopes for the different resources I have. For example, I have users and photos as different scopes/resources, and they have different store names (lets say 'users' and 'photos').


      When using the default pouchDB factory, a different IndexedDB is created for each of my scopes (if they have different names). After changing my code to use SQLite instead of IndexedDB, I noticed that the same behavior occurs, so different SQLite databases are created for each of my scopes/resources.


      So, my questions is:


      What would be the best implementation of Offline Persistence Toolkit and SQLite in terms of offline querying performance? Is it possible to set Offline Persistence Toolkit to have only 1 database and have different tables for each scope/resource, and then do joins and queries on it to take advantage of SQLite, for example?


      The reason I am asking that is because the data I need to work with might be really big; consequently, a local database might also get big. Furthermore, I have already experienced some considerable delays when querying data offline as the local database grows bigger, especially on mobile devices.


      Thank you,


        • 1. Re: Offline Persistence Toolkit - SQLite

          OPT heavily relies on PouchDB for client side storage management. PouchDB is the wrapper that provides consistent API across different underlying actual storage implementations. The actual storage to use is controlled by adapters to use. By default, PouchDB uses indexedDB to store data. OPT provides a way for consumer to configure what storage to use by allowing developers to provider adapter to be plugged in.


          At high level, PouchDB is a NoSQL DB, it only has stores. Databases in CouchDB/PouchDB are more like tables than databases in an RDBMS. Whenever OPT creates a PouchDB store, the adapter interacts with SQLite by creating a SQLite database, this is something OPT cannot control, but there are some plugins available (https://github.com/pouchdb-community/relational-pouch ) to make the PouchDB more relational. On the other hand, client side storage should not be a replacement for server side storage. Do you have more specific details on why you need to do joins and complicated queries on client side?


          Thank you,