3

I have a parent-child relationship table in my database (tree system), and each child has a parent and each parent has some children.

My back-end is PHP and my database is MySql, I get all rows of my table (categories) then insert all of them in indexedDB. and working with that is so easy and good.

Everything is OK except synchronization! Imagine I have some users and all of them are editing just one row at same time. I get all my table rows and add it to indexedDB by each refreshing (F5) I mean when user get the page all rows are fresh, but when a user edit a row and other user are also editing, they can't see changes that other users made.

How to do a real-time synchronization by PHP and MySql and dexie.js?

Jhonsborg
  • 31
  • 3

1 Answers1

0

Dexie supports CRUD hooks. It will intercept any changes to the client database. On that API, it is possible to build synchronization with server. Both client and server needs to track changes and interchange the changes done since a specific revision or time stamp.

There's an add-on to dexie called Dexie.Syncable that does this for you client-side. It's not stable though but try it out and see if it solves what you need. There's an example of server implementation on in-memory database to use as a template for building the server part.

David Fahlander
  • 5,058
  • 1
  • 20
  • 19