]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/shared/abstract-run-query.ts
Refactor a little bit raw sql builders
[github/Chocobozzz/PeerTube.git] / server / models / shared / abstract-run-query.ts
similarity index 70%
rename from server/models/video/sql/video/shared/abstract-run-query.ts
rename to server/models/shared/abstract-run-query.ts
index 8e7a7642d0513835988ef92727bc7b6f751606ca..c39b7bcfe0bf5e33d1e7af9900037072db0b6b68 100644 (file)
@@ -7,18 +7,20 @@ import { QueryTypes, Sequelize, Transaction } from 'sequelize'
  */
 
 export class AbstractRunQuery {
-  protected sequelize: Sequelize
-
   protected query: string
   protected replacements: any = {}
 
-  protected runQuery (options: { transaction?: Transaction, logging?: boolean } = {}) {
+  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: false
+      nest: options.nest ?? false
     }
 
     return this.sequelize.query<any>(this.query, queryOptions)