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