ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

abstract-run-query.ts 782 B

1234567891011121314151617181920212223242526272829303132
  1. import { QueryTypes, Sequelize, Transaction } from 'sequelize'
  2. /**
  3. *
  4. * Abstract builder to run video SQL queries
  5. *
  6. */
  7. export class AbstractRunQuery {
  8. protected query: string
  9. protected replacements: any = {}
  10. constructor (protected readonly sequelize: Sequelize) {
  11. }
  12. protected runQuery (options: { nest?: boolean, transaction?: Transaction, logging?: boolean } = {}) {
  13. const queryOptions = {
  14. transaction: options.transaction,
  15. logging: options.logging,
  16. replacements: this.replacements,
  17. type: QueryTypes.SELECT as QueryTypes.SELECT,
  18. nest: options.nest ?? false
  19. }
  20. return this.sequelize.query<any>(this.query, queryOptions)
  21. }
  22. protected buildSelect (entities: string[]) {
  23. return `SELECT ${entities.join(', ')} `
  24. }
  25. }