1
0
Fork 0
peertube/server/models/shared/update.ts

25 lines
557 B
TypeScript
Raw Normal View History

2023-01-10 05:09:30 -05:00
import { QueryTypes, Sequelize, Transaction } from 'sequelize'
// Sequelize always skip the update if we only update updatedAt field
2023-01-10 05:09:30 -05:00
function setAsUpdated (options: {
sequelize: Sequelize
table: string
id: number
transaction?: Transaction
}) {
const { sequelize, table, id, transaction } = options
return sequelize.query(
`UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`,
{
replacements: { table, id, updatedAt: new Date() },
type: QueryTypes.UPDATE,
transaction
}
)
}
export {
setAsUpdated
}