Answer the question
In order to leave comments, you need to log in
How to update nodejs application so as not to lose data?
On my site, people open different pages, view and edit them.
Each action is tracked on the server via websockets.
I wrote a small nodejs application for this, something like this:
let modifyingPages = 0;
let browsingPages = 0;
let creatingPages = 0;
ws.on('message', json => {
const msg = JSON.parse(json);
if (msg.type === 'startModifyPage') {
this.modifyingPages++;
} else if (msg.type === 'finishModifyPage') {
this.modifyingPages--;
} else if (msg.type === 'startBrowsePage') {
this.browsingPages ++-;
} else if (msg.type === 'finishBrowsePage') {
this.browsingPages --;
} else if (msg.type === 'startCreatePage') {
this.creatingPages ++;
} else if (msg.type === 'finishCreatePage') {
this.creatingPages --;
}
});
Answer the question
In order to leave comments, you need to log in
Save in a separate place.
For example, if you do not want to raise a separate database, then you can locally mark data that did not go to your database.
If the local data is equal to the data in the database, then clean the local data, and if not, then upload it to yourself, and then clean it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question