diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
commit | fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58 (patch) | |
tree | bd626648077f84fb4628af3a37acf260597fa0ef /server/models/shared/update.ts | |
parent | f68d1cb6ac4aa4fb563b9eeb831fccffee260b2f (diff) | |
download | PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.gz PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.zst PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.zip |
Filter host for channels and playlists search
Diffstat (limited to 'server/models/shared/update.ts')
-rw-r--r-- | server/models/shared/update.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/server/models/shared/update.ts b/server/models/shared/update.ts new file mode 100644 index 000000000..d338211e3 --- /dev/null +++ b/server/models/shared/update.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { QueryTypes, Transaction } from 'sequelize' | ||
2 | import { sequelizeTypescript } from '@server/initializers/database' | ||
3 | |||
4 | // Sequelize always skip the update if we only update updatedAt field | ||
5 | function setAsUpdated (table: string, id: number, transaction?: Transaction) { | ||
6 | return sequelizeTypescript.query( | ||
7 | `UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`, | ||
8 | { | ||
9 | replacements: { table, id, updatedAt: new Date() }, | ||
10 | type: QueryTypes.UPDATE, | ||
11 | transaction | ||
12 | } | ||
13 | ) | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | setAsUpdated | ||
18 | } | ||