S
S
Sergo Sergo2014-11-20 17:59:30
MySQL
Sergo Sergo, 2014-11-20 17:59:30

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

3 answer(s)
D
Dmitry Mironov, 2014-11-20
@MironovDV

If you need to perform operations in the database when inserting, then you can use triggers habrahabr.ru/post/37693

D
Dmitry Entelis, 2014-11-20
@DmitriyEntelis

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

V
Vyacheslav Uspensky, 2014-11-20
@Kwisatz

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 question

Ask a Question

731 491 924 answers to any question