aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/shared/update.ts
blob: d338211e380bbc5cf27cf15148df1d09ec932016 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { QueryTypes, Transaction } from 'sequelize'
import { sequelizeTypescript } from '@server/initializers/database'

// Sequelize always skip the update if we only update updatedAt field
function setAsUpdated (table: string, id: number, transaction?: Transaction) {
  return sequelizeTypescript.query(
    `UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`,
    {
      replacements: { table, id, updatedAt: new Date() },
      type: QueryTypes.UPDATE,
      transaction
    }
  )
}

export {
  setAsUpdated
}