Answer the question
In order to leave comments, you need to log in
Node JS + Mysql How to constantly check for new elements in the database?
How best to organize a constant check for the appearance of new elements in the database. I thought through a timer, maybe there is a better way?
Answer the question
In order to leave comments, you need to log in
If you need to perform operations in the database when inserting, then you can use triggers habrahabr.ru/post/37693
It seems to me that for such stories it is much better to implement logic at the application level that when a new record is created, a notification about this event, or even the event itself, gets into a certain mailing list from which everyone reads it.
The RabbitMQ queue server, or at least Redis, is great for this.
UPD The above is true if someone other than your application on node.js writes to your database
If you insert into the database from the application, then organize the notification of all related objects in the same place.
If using third-party methods, then the timer is a completely normal solution, but the request is better to use prepared (if your driver uses native prepared instead of emulation, but I didn’t see such a node)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question