diff options
author | Chocobozzz <me@florianbigard.com> | 2023-01-09 10:29:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-01-09 10:29:23 +0100 |
commit | eb66ee88351a93eb68c366cfbe30d35ed7c57b03 (patch) | |
tree | fb2ebb3b5accbbf06438709ae7e222f7ea7c9ffd /server/models/account/account.ts | |
parent | 0a8a79552cf59c800011c9f63eaa8658230acddc (diff) | |
download | PeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.tar.gz PeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.tar.zst PeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.zip |
Refactor table attributes
Diffstat (limited to 'server/models/account/account.ts')
-rw-r--r-- | server/models/account/account.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 8a7dfba94..fca1b7b6d 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -38,7 +38,7 @@ import { ApplicationModel } from '../application/application' | |||
38 | import { ServerModel } from '../server/server' | 38 | import { ServerModel } from '../server/server' |
39 | import { ServerBlocklistModel } from '../server/server-blocklist' | 39 | import { ServerBlocklistModel } from '../server/server-blocklist' |
40 | import { UserModel } from '../user/user' | 40 | import { UserModel } from '../user/user' |
41 | import { getSort, throwIfNotValid } from '../utils' | 41 | import { buildSQLAttributes, getSort, throwIfNotValid } from '../utils' |
42 | import { VideoModel } from '../video/video' | 42 | import { VideoModel } from '../video/video' |
43 | import { VideoChannelModel } from '../video/video-channel' | 43 | import { VideoChannelModel } from '../video/video-channel' |
44 | import { VideoCommentModel } from '../video/video-comment' | 44 | import { VideoCommentModel } from '../video/video-comment' |
@@ -251,6 +251,18 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> { | |||
251 | return undefined | 251 | return undefined |
252 | } | 252 | } |
253 | 253 | ||
254 | // --------------------------------------------------------------------------- | ||
255 | |||
256 | static getSQLAttributes (tableName: string, aliasPrefix = '') { | ||
257 | return buildSQLAttributes({ | ||
258 | model: this, | ||
259 | tableName, | ||
260 | aliasPrefix | ||
261 | }) | ||
262 | } | ||
263 | |||
264 | // --------------------------------------------------------------------------- | ||
265 | |||
254 | static load (id: number, transaction?: Transaction): Promise<MAccountDefault> { | 266 | static load (id: number, transaction?: Transaction): Promise<MAccountDefault> { |
255 | return AccountModel.findByPk(id, { transaction }) | 267 | return AccountModel.findByPk(id, { transaction }) |
256 | } | 268 | } |