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





                                           





                                         
                                                                                       


                                       

                                                   
                 

     
                                                              

   
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,
      next: false
    }

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