Node.js + Mysql Event Scheduler: how?
<p>I am building a product management platform using node.js and my data is saved in a MySQL database.
At this point I needed to use MySQL's event scheduler to perform some actions at specific times and it all goes great when I test it in the MySQL console but when it comes to do it through node.js I am having the following error:</p>

<blockquote>
  <p>Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$ CREATE EVENT IF NOT EXISTS test     ON SCHEDULE AT DATE_ADD(NOW(), ' at line 1</p>
</blockquote>

<p>I am using <a href="https://github.com/dresende/node-orm2" rel="nofollow">node-orm2</a> to connect to my database and I am doing the following</p>

<pre><code>var query = 'DROP EVENT IF EXISTS test;' +
  ' DELIMITER $$' +
  ' CREATE EVENT IF NOT EXISTS test' +
  '     ON SCHEDULE AT DATE_ADD(NOW(), INTERVAL 10 SECOND) ON COMPLETION PRESERVE ENABLE' +
  '     DO BEGIN' +
  '     SELECT @data_id:=quiz_platforms_has_quiz_data.quiz_data_id,' +
  '             @date_end:=quiz_platforms_has_quiz_data.timestamp_end' +
  '     FROM quiz_platforms_has_quiz_data' +
  '         WHERE quiz_platforms_has_quiz_data.quiz_platforms_id=5' +
  '         AND quiz_platforms_has_quiz_data.timestamp_start &gt;= CURDATE()' +
  '         ORDER BY timestamp_start LIMIT 1;' +
  '     UPDATE quiz_platforms SET quiz_platforms.current_quiz_id=@data_id' +
  '         WHERE quiz_platforms.id=5;' +
  '     IF @date_end&gt;0 THEN' +
  '         ALTER EVENT test ON SCHEDULE AT @date_end;' +
  '         ALTER EVENT test ENABLE;' +
  '     ELSE' +
  '         DROP EVENT test;' +
  '     END IF;' +
  '     END $$' +
  ' DELIMITER ; ';
orm_db.driver.execQuery(query, function(err, result) {
  if (err) {
    console.log(NOW + " - [DB-Event-ERR] " + err);
  }
});
</code></pre>

<p>The thing is: I already know neither this library nor node-mysql itself support this and I wanted to know if there is a way.</p>

<p>I also thought about using a cron manager and do this from the server instead of using the database's event schedule but I have no idea what would be the lightest solution.</p>

<p>[EDIT]</p>

<p>I need to use the event scheduler through node.js and I haven't successfully done it. I can't reveal much details because of company policy. Let's just say we have devices that run a certain task during a time interval. I have to update a column in a database table so that it represents which task is currently running in that device.</p>

<p>table devices (columns): id, name, description, current_task;</p>

<p>table tasks(columns): id, name, description;</p>

<p>So if I were to check the device current_task, I would know just by going to the device's table.</p>

<p>I have to be able to update that column's value as soon as the task changes.</p>