import { QueryTypes } from "sequelize" ; import * as SqlConnection from "sequelize" ; import { sequelize } from "./sequelize.config" ; export class SqlHelper { private _sequelize : SqlConnection . Sequelize ; private params = { } ; constructor ( private query ) { this . _sequelize = sequelize . getSequelize ( ) ; } public addParameter ( parameterName , value ) { this . params [ parameterName ] = value ; } public addValues ( values ) { this . params = { ... this . params , ... values } ; } public async execute ( ) { return this . _sequelize . query ( this . query , { replacements : this . params , type : QueryTypes . RAW , } ) ; } public async select ( ) { return this . _sequelize . query ( this . query , { replacements : this . params , type : QueryTypes . SELECT , } ) ; } public async insert ( ) { return this . _sequelize . query ( this . query , { replacements : this . params , type : QueryTypes . INSERT , } ) ; } public async update ( ) { return this . _sequelize . query ( this . query , { replacements : this . params , type : QueryTypes . UPDATE , } ) ; } public async delete ( ) { return this . _sequelize . query ( this . query , { replacements : this . params , type : QueryTypes . DELETE , } ) ; } public async authenticate ( ) { return this . _sequelize . authenticate ( ) ; } }