1
0
Fork 0
peertube/server/models/video/sql/shared/abstract-run-query.ts

27 lines
623 B
TypeScript
Raw Normal View History

2021-06-10 12:43:55 +00:00
import { QueryTypes, Sequelize, Transaction } from 'sequelize'
2021-06-10 14:57:13 +00:00
/**
*
* Abstact builder to run video SQL queries
*
*/
2021-11-02 10:00:40 +00:00
export class AbstractRunQuery {
2021-06-10 12:43:55 +00:00
protected sequelize: Sequelize
protected query: string
protected replacements: any = {}
2021-06-11 12:09:33 +00:00
protected runQuery (options: { transaction?: Transaction, logging?: boolean } = {}) {
const queryOptions = {
transaction: options.transaction,
logging: options.logging,
2021-06-10 12:43:55 +00:00
replacements: this.replacements,
type: QueryTypes.SELECT as QueryTypes.SELECT,
2021-06-17 14:02:38 +00:00
nest: false
2021-06-10 12:43:55 +00:00
}
2021-06-11 12:09:33 +00:00
return this.sequelize.query<any>(this.query, queryOptions)
2021-06-10 12:43:55 +00:00
}
}