R
R
rozochkin2015-06-30 20:39:42
JavaScript
rozochkin, 2015-06-30 20:39:42

JS web application data sync with database?

Hello
There is a web application in JS and the ability to create a local database.
And there is a Python / Django backend (in principle, this does not really matter).
The format of JSON data received from the server, data such as user, user group, text, path to the picture, etc., that is, notes of users created in different groups.
Loading notes are divided into groups.
Each user, when starting the application, has a list of groups in which he is a member, and a list of notes related to these groups.
These notes should be updated when you refresh the page, or force a refresh in the app.
The question is, how can you synchronize data in order to avoid loading the entire sheet every time?
For now, page-by-page/partial retrieval of information should be excluded. It's good to have a list right away.
I thought to have a version of the list every time the group changes, and to form a common list depending on the changed groups. But it turns out with any change in the text, you will have to load the entire group.
Are there smarter ways?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Arutyunov, 2015-07-01
@arutyunov

On the JS side, what are you currently using? Any frameworks?
If this is an attempt to make a real-time application, then isn't it easier to connect a node for this?
And it turns out that you have a collection of models with groups, when you update a group, you update only 1 model of this group itself, without affecting the entire collection. Well, at the right time, the server itself will send you updated data for each of the models.
Well, in general, it’s not entirely clear from the task - do you have data from each group changing almost simultaneously and constantly? How does the user's notes themselves change without the participation of the user himself?

R
rozochkin, 2015-07-06
@rozochkin

So far, the temporary solution is:
-Each note has a modification date -On the
first request, we get all the notes from the clients, and the server synchronization date
-Save the notes to the local database -After
10 minutes, send a request with our last synchronization date
-Filter on the server what has changed after it
-We get only the changed data
-Update the data in the local database + add new ones
It is possible to change the general version of the database/group every time the note is changed, and send this version instead of the date.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question