2021-06-10 14:43:55 +02:00
|
|
|
import { QueryTypes, Sequelize, Transaction } from 'sequelize'
|
|
|
|
import { logger } from '@server/helpers/logger'
|
|
|
|
|
2021-06-10 16:57:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Abstact builder to run video SQL queries
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-06-10 14:43:55 +02:00
|
|
|
export class AbstractVideosQueryBuilder {
|
|
|
|
protected sequelize: Sequelize
|
|
|
|
|
|
|
|
protected query: string
|
|
|
|
protected replacements: any = {}
|
|
|
|
|
|
|
|
protected runQuery (transaction?: Transaction, nest?: boolean) {
|
|
|
|
logger.debug('Running videos query.', { query: this.query, replacements: this.replacements })
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
transaction,
|
|
|
|
replacements: this.replacements,
|
|
|
|
type: QueryTypes.SELECT as QueryTypes.SELECT,
|
|
|
|
nest
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.sequelize.query<any>(this.query, options)
|
|
|
|
}
|
|
|
|
}
|