Q:

Using a datetime function on a column using Sequelize

I'm trying to calculate the difference (in seconds) between CURRENT_TIMESTAMP and a DATETIME column. I've just used TIMESTAMPDIFF(SECOND, CURRENT_TIMESTAMP, someColumnName) in SQL, but I am having trouble doing this using Sequelize.
I've tried doing something like this, but I can't seem to get the syntax right:
  Project
    .findAll({
      include: [Note, Link],
      attributes: [
        [sequelize.fn('TIMESTAMPDIFF', 'SECOND', 'CURRENT_TIMESTAMP', 'createdAt'), 'diff']
      ]
    })
    .then(res.send.bind(res));

Is there a way of adding using a function as an attribute using Sequelize?

A:

Use sequelize.col to mark the column (otherwise it will be escaped as a string)
sequelize.fn('TIMESTAMPDIFF', 'SECOND', 'CURRENT_TIMESTAMP', sequelize.col('createdAt'))

