update.ts 527 B

123456789101112131415161718
  1. import { QueryTypes, Transaction } from 'sequelize'
  2. import { sequelizeTypescript } from '@server/initializers/database'
  3. // Sequelize always skip the update if we only update updatedAt field
  4. function setAsUpdated (table: string, id: number, transaction?: Transaction) {
  5. return sequelizeTypescript.query(
  6. `UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`,
  7. {
  8. replacements: { table, id, updatedAt: new Date() },
  9. type: QueryTypes.UPDATE,
  10. transaction
  11. }
  12. )
  13. }
  14. export {
  15. setAsUpdated
  16. }