]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/shared/update.ts
d02c4535dc5ec02783d6bdd2891c3f01df23a30c
[github/Chocobozzz/PeerTube.git] / server / models / shared / update.ts
1 import { QueryTypes, Sequelize, Transaction } from 'sequelize'
2
3 // Sequelize always skip the update if we only update updatedAt field
4 function setAsUpdated (options: {
5 sequelize: Sequelize
6 table: string
7 id: number
8 transaction?: Transaction
9 }) {
10 const { sequelize, table, id, transaction } = options
11
12 return sequelize.query(
13 `UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`,
14 {
15 replacements: { table, id, updatedAt: new Date() },
16 type: QueryTypes.UPDATE,
17 transaction
18 }
19 )
20 }
21
22 export {
23 setAsUpdated
24 }