Answer the question
In order to leave comments, you need to log in
How can I understand in NodeJS that the table has changed (and notify the client further)?
Those. about the client/server connection itself, I understand how it's done and how I can send requests.
But how to run a function on the server that will determine that the table has changed, and immediately send the information to the client? Those. how to me to track the fact of change of the table.
PS: I want a way without using timers and reading / comparing with the old timer data, the only way that comes to my mind is to track all INSERT / UPDATE / DELETE (and then immediately send information after them that the table has changed), but if I manually change the data in the SQL editor, it won't work anymore :)
Answer the question
In order to leave comments, you need to log in
Do you only have a node in charge of database modifications? if yes, then in the code where you do this, add the dispatch of the event, add the dispatch of the event myemitter('emit'..... and hang up myemitter.on('emit'... event handling.
Docs for reading here
Ideally, to work with the base, you need to create a separate class in which you can call anything on the corresponding methods.
As already suggested above, rethinkDB is an ideal option.
But if relationals are fundamental, then we write triggers on the necessary tables, which add up the necessary changes separately, and the script periodically checks them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question