mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
32
server/core/models/shared/abstract-run-query.ts
Normal file
32
server/core/models/shared/abstract-run-query.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { QueryTypes, Sequelize, Transaction } from 'sequelize'
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract builder to run video SQL queries
|
||||
*
|
||||
*/
|
||||
|
||||
export class AbstractRunQuery {
|
||||
protected query: string
|
||||
protected replacements: any = {}
|
||||
|
||||
constructor (protected readonly sequelize: Sequelize) {
|
||||
|
||||
}
|
||||
|
||||
protected runQuery (options: { nest?: boolean, transaction?: Transaction, logging?: boolean } = {}) {
|
||||
const queryOptions = {
|
||||
transaction: options.transaction,
|
||||
logging: options.logging,
|
||||
replacements: this.replacements,
|
||||
type: QueryTypes.SELECT as QueryTypes.SELECT,
|
||||
nest: options.nest ?? false
|
||||
}
|
||||
|
||||
return this.sequelize.query<any>(this.query, queryOptions)
|
||||
}
|
||||
|
||||
protected buildSelect (entities: string[]) {
|
||||
return `SELECT ${entities.join(', ')} `
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue