1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Add raw SQL query support

This commit is contained in:
toast-ts 2024-02-08 07:36:37 +11:00
parent 1d02e781dc
commit ab9e88c263
8 changed files with 8 additions and 0 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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});

View File

@ -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}});

View File

@ -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'})

View File

@ -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});

View File

@ -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}});

View File

@ -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});