]>
Commit | Line | Data |
---|---|---|
d9bf974f C |
1 | import { QueryTypes, Sequelize, Transaction } from 'sequelize' |
2 | import { logger } from '@server/helpers/logger' | |
3 | ||
1d43c3a6 C |
4 | /** |
5 | * | |
6 | * Abstact builder to run video SQL queries | |
7 | * | |
8 | */ | |
9 | ||
d9bf974f C |
10 | export class AbstractVideosQueryBuilder { |
11 | protected sequelize: Sequelize | |
12 | ||
13 | protected query: string | |
14 | protected replacements: any = {} | |
15 | ||
16 | protected runQuery (transaction?: Transaction, nest?: boolean) { | |
17 | logger.debug('Running videos query.', { query: this.query, replacements: this.replacements }) | |
18 | ||
19 | const options = { | |
20 | transaction, | |
21 | replacements: this.replacements, | |
22 | type: QueryTypes.SELECT as QueryTypes.SELECT, | |
23 | nest | |
24 | } | |
25 | ||
26 | return this.sequelize.query<any>(this.query, options) | |
27 | } | |
28 | } |