From ab9e88c263849f6b0b1a46fd3a7e18f96c649951 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Thu, 8 Feb 2024 07:36:37 +1100 Subject: [PATCH] Add raw SQL query support --- src/models/MPServer.ts | 1 + src/models/dailyMsgs.ts | 1 + src/models/prohibitedWords.ts | 1 + src/models/punishments.ts | 1 + src/models/suggestions.ts | 1 + src/models/tagSystem.ts | 1 + src/models/userLevels.ts | 1 + src/models/ytChannels.ts | 1 + 8 files changed, 8 insertions(+) diff --git a/src/models/MPServer.ts b/src/models/MPServer.ts index d19ec8b..5dfec2e 100644 --- a/src/models/MPServer.ts +++ b/src/models/MPServer.ts @@ -55,6 +55,7 @@ export class MPServerSvc { }) this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); async fetchPlayerData(serverName:string) { const findServerByName = await this.model.findOne({where: {serverName: serverName}}); if (findServerByName) return findServerByName.dataValues.playerData; diff --git a/src/models/dailyMsgs.ts b/src/models/dailyMsgs.ts index 23c2493..8025a3a 100644 --- a/src/models/dailyMsgs.ts +++ b/src/models/dailyMsgs.ts @@ -30,6 +30,7 @@ export class DailyMsgsSvc { }) this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); nukeDays = async()=>await this.model.destroy({truncate: true}); fetchDays = async()=>await this.model.findAll(); async newDay(formattedDate:number, total:number) { diff --git a/src/models/prohibitedWords.ts b/src/models/prohibitedWords.ts index eb460bc..371cee5 100644 --- a/src/models/prohibitedWords.ts +++ b/src/models/prohibitedWords.ts @@ -25,6 +25,7 @@ export class ProhibitedWordsSvc { }) this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); findWord = async(word:string)=>await this.model.findByPk(word); getAllWords = async()=>await this.model.findAll(); insertWord = async(word:string)=>await this.model.create({word: word}); diff --git a/src/models/punishments.ts b/src/models/punishments.ts index 8f37da3..fca7fd6 100644 --- a/src/models/punishments.ts +++ b/src/models/punishments.ts @@ -83,6 +83,7 @@ export class PunishmentsSvc { }); this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); async updateReason(caseId:number, reason:string) { const findCase = this.findCase(caseId); if (findCase) return this.model.update({reason: reason}, {where: {case_id: caseId}}); diff --git a/src/models/suggestions.ts b/src/models/suggestions.ts index 4fc19ca..5414d98 100644 --- a/src/models/suggestions.ts +++ b/src/models/suggestions.ts @@ -40,6 +40,7 @@ export class SuggestionsSvc { }) this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); fetchById = async(id:number)=>await this.model.findByPk(id); updateStatus = async(id:number, status:string)=>await this.model.update({status: status}, {where: {id: id}}); create =(userid:string, description:string)=>this.model.create({userid: userid, suggestion: description, status: 'Pending'}) diff --git a/src/models/tagSystem.ts b/src/models/tagSystem.ts index 936e4ab..e727c4a 100644 --- a/src/models/tagSystem.ts +++ b/src/models/tagSystem.ts @@ -50,6 +50,7 @@ export class TagSystemSvc { }); this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); async createTag(userid:string, tagName:string, message:string, embedFlag:boolean) { CacheServer.delete('tags'); return await this.model.create({userid: userid, tagname: tagName, message: message.replace(/\\n/g, '\n'), embedFlag: embedFlag}); diff --git a/src/models/userLevels.ts b/src/models/userLevels.ts index cd2708f..87fb146 100644 --- a/src/models/userLevels.ts +++ b/src/models/userLevels.ts @@ -57,6 +57,7 @@ export class UserLevelsSvc { }); this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); fetchEveryone = async()=>await this.model.findAll(); fetchUser = async(userId:string)=>await this.model.findByPk(userId); deleteUser = async(userId:string)=>await this.model.destroy({where: {id: userId}}); diff --git a/src/models/ytChannels.ts b/src/models/ytChannels.ts index dfebd56..5ba94e4 100644 --- a/src/models/ytChannels.ts +++ b/src/models/ytChannels.ts @@ -34,6 +34,7 @@ export class YouTubeChannelsSvc { }) this.model.sync(); } + query = async(pattern:string)=>await this.model.sequelize.query(pattern); async addChannel(YTChannelID:string, DCChannelID:string, DCRole:string) { if (await this.model.findOne({where: {ytchannel: YTChannelID}})) return false; await this.model.create({ytchannel: YTChannelID, dcchannel: DCChannelID, dcrole: DCRole});