typicaljoe / taffydb

TaffyDB - an open source JavaScript Database for your browser
http://taffydb.com
MIT License
2.21k stars 286 forks source link

Sync to server database? #170

Open pwFoo opened 3 years ago

pwFoo commented 3 years ago

Hi, would be nice to have a option to sync changes to server backend like mysql, postgres or a headless cms (directus)?

To keep it simple maybe there is a way to add a event listener for insert, update and delete actions of tuffydb? Event callback could be used to sync changes to the backend.

But to deal with offline clients maybe a service worker and event queue is needed to update changes during client was offline...

What do you think? Would it a possible extension or do you see problems with such a feature?

TuffyDB ist awesome! It's great to use queries for array of objects! 👍

pwFoo commented 3 years ago

I thank that could be done by hook localstorage store / sync feature? Is there a way to hook into that write / read to localstorage and trigger a custom function / extension?

At the moment I plan to use taffydb as client site cache of data to work offline. So just updates, deletes and inserts need to be queued and send to a server api / db.

To update cache it would be easier to replace the data... Won't work for all applications because of client and server side data changes, but with small offline working apps without much server side changes...