From eb66ee88351a93eb68c366cfbe30d35ed7c57b03 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 9 Jan 2023 10:29:23 +0100 Subject: Refactor table attributes --- server/models/account/account.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'server/models/account/account.ts') 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' import { ServerModel } from '../server/server' import { ServerBlocklistModel } from '../server/server-blocklist' import { UserModel } from '../user/user' -import { getSort, throwIfNotValid } from '../utils' +import { buildSQLAttributes, getSort, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { VideoCommentModel } from '../video/video-comment' @@ -251,6 +251,18 @@ export class AccountModel extends Model>> { return undefined } + // --------------------------------------------------------------------------- + + static getSQLAttributes (tableName: string, aliasPrefix = '') { + return buildSQLAttributes({ + model: this, + tableName, + aliasPrefix + }) + } + + // --------------------------------------------------------------------------- + static load (id: number, transaction?: Transaction): Promise { return AccountModel.findByPk(id, { transaction }) } -- cgit v1.2.3