aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/models/video/sql/shared/abstract-run-query.ts
blob: 8e7a7642d0513835988ef92727bc7b6f751606ca (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                              
 





                                           
                               




                                  
                                                                                       


                                       

                                                   
                 

     
                                                              

   
import { QueryTypes, Sequelize, Transaction } from 'sequelize'

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

export class AbstractRunQuery {
  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)
  }
}