aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql/shared/abstract-videos-query-builder.ts
blob: 09776bcb0e88585f0dc0a350e20bae15b907757c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { QueryTypes, Sequelize, Transaction } from 'sequelize'

/**
 *
 * Abstact builder to run video SQL queries
 *
 */

export class AbstractVideosQueryBuilder {
  protected sequelize: Sequelize

  protected query: string
  protected replacements: any = {}

  protected runQuery (options: { transaction?: Transaction, logging?: boolean } = {}) {
    const queryOptions = {
      transaction: options.transaction,
      logging: options.logging,
      replacements: this.replacements,
      type: QueryTypes.SELECT as QueryTypes.SELECT,
      nest: false
    }

    return this.sequelize.query<any>(this.query, queryOptions)
  }
}