]>
Commit | Line | Data |
---|---|---|
d9bf974f | 1 | import { QueryTypes, Sequelize, Transaction } from 'sequelize' |
d9bf974f | 2 | |
1d43c3a6 C |
3 | /** |
4 | * | |
7a4fd56c | 5 | * Abstract builder to run video SQL queries |
1d43c3a6 C |
6 | * |
7 | */ | |
8 | ||
7e7d8e48 | 9 | export class AbstractRunQuery { |
d9bf974f C |
10 | protected query: string |
11 | protected replacements: any = {} | |
12 | ||
156c44c8 C |
13 | constructor (protected readonly sequelize: Sequelize) { |
14 | ||
15 | } | |
16 | ||
17 | protected runQuery (options: { nest?: boolean, transaction?: Transaction, logging?: boolean } = {}) { | |
71d4af1e C |
18 | const queryOptions = { |
19 | transaction: options.transaction, | |
20 | logging: options.logging, | |
d9bf974f C |
21 | replacements: this.replacements, |
22 | type: QueryTypes.SELECT as QueryTypes.SELECT, | |
156c44c8 | 23 | nest: options.nest ?? false |
d9bf974f C |
24 | } |
25 | ||
71d4af1e | 26 | return this.sequelize.query<any>(this.query, queryOptions) |
d9bf974f | 27 | } |
bae61627 C |
28 | |
29 | protected buildSelect (entities: string[]) { | |
30 | return `SELECT ${entities.join(', ')} ` | |
31 | } | |
d9bf974f | 32 | } |