thombruce / toodles

✅ A super simple todo app
https://toodles.thombruce.com/
GNU General Public License v3.0
0 stars 0 forks source link

Persistence: Save to IndexedDB #5

Closed thombruce closed 1 year ago

thombruce commented 1 year ago

Users should be able to save their todos, close the application (or browser tab) and return at a later time with their todos loaded from a stored location.

The obvious choice for this in browser is IndexedDB, which we can interface with directly or via a library like DexieJS or LokiJS.

LokiJS is probably the route we'll go since it has numerous adapters including IndexedDB and the local file system on desktop (not sure about mobile).

thombruce commented 1 year ago

Eventual syncing between devices will require a server-based backend. LokiJS recommends SyncProxy, PouchDB is an alternative that integrates with CouchDB. Each worth a look. Simplicity is desirable.

thombruce commented 1 year ago

Might try out PouchDB for ease of integration with CouchDB, which should significantly reduce complexity of deploying online persistence. The difficulty is... authentication/authorisation and integration with a payment gateway (if I intend to run a server for others to use). Note: Toodles will always be open source for anyone to use freely, including whatever server code we end up writing; we should also consider what is easiest for a novice developer to setup for their self-hosted usage.

thombruce commented 1 year ago

Re payment and authorisation:

It might just be better to host our own API with a database backend of our choosing. This way we can integrate and connect disparate entities like MongoDB and a Stripe payment gateway, and we can authorise usage based on our own validations (e.g. storage usage, number of records. This is less straightforward, but more configurable and ultimately probably less of a headache.

As to what stack we use on the server... Rails is my go-to, but given that this is a JS project and a relatively simple one maybe we should look into an Express-based stack (Sails?).

thombruce commented 1 year ago

Note: Desktop target is Electron; Mobile target is probably Capacitor (https://capacitorjs.com/). This is worth looking into and deciding on before selecting a persistence solution. Can LokiJS work with Capacitor? Can some other database adapter work with all three environments?

thombruce commented 1 year ago

Right now, looking at:

All implementations can make use of Pinia for in-memory store if necessary (in previous experiments with LokiJS, I simply wrapped a deep ref object around Loki's own in-memory database).

thombruce commented 1 year ago

Loki has a "nativescript" (no capitalisation in documentation) adapter, as well as community-made Cordova and LocalForage adapters:

There are NativeScript adapters for Capacitor if necessary: https://docs.nativescript.org/capacitor/

There's also a guide to using NativeScript with Vue here: https://docs.nativescript.org/tutorial/vue.html. Getting a mobile version working is gonna be a major learning experience, but there's good documentation and excellent tools to take the edge off.

thombruce commented 1 year ago

LokiJS still looking like the GOAT, just for the sheer variation of adapters allowing for storage approaches appropriate for each environment.

Decision made? LokiJS?