mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Add raw SQL query support
This commit is contained in:
parent
3170de7ead
commit
b58bcc59bb
@ -55,6 +55,7 @@ export class MPServerSvc {
|
|||||||
})
|
})
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
async fetchPlayerData(serverName:string) {
|
async fetchPlayerData(serverName:string) {
|
||||||
const findServerByName = await this.model.findOne({where: {serverName: serverName}});
|
const findServerByName = await this.model.findOne({where: {serverName: serverName}});
|
||||||
if (findServerByName) return findServerByName.dataValues.playerData;
|
if (findServerByName) return findServerByName.dataValues.playerData;
|
||||||
|
@ -30,6 +30,7 @@ export class DailyMsgsSvc {
|
|||||||
})
|
})
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
nukeDays = async()=>await this.model.destroy({truncate: true});
|
nukeDays = async()=>await this.model.destroy({truncate: true});
|
||||||
fetchDays = async()=>await this.model.findAll();
|
fetchDays = async()=>await this.model.findAll();
|
||||||
async newDay(formattedDate:number, total:number) {
|
async newDay(formattedDate:number, total:number) {
|
||||||
|
@ -25,6 +25,7 @@ export class ProhibitedWordsSvc {
|
|||||||
})
|
})
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
findWord = async(word:string)=>await this.model.findByPk(word);
|
findWord = async(word:string)=>await this.model.findByPk(word);
|
||||||
getAllWords = async()=>await this.model.findAll();
|
getAllWords = async()=>await this.model.findAll();
|
||||||
insertWord = async(word:string)=>await this.model.create({word: word});
|
insertWord = async(word:string)=>await this.model.create({word: word});
|
||||||
|
@ -83,6 +83,7 @@ export class PunishmentsSvc {
|
|||||||
});
|
});
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
async updateReason(caseId:number, reason:string) {
|
async updateReason(caseId:number, reason:string) {
|
||||||
const findCase = this.findCase(caseId);
|
const findCase = this.findCase(caseId);
|
||||||
if (findCase) return this.model.update({reason: reason}, {where: {case_id: caseId}});
|
if (findCase) return this.model.update({reason: reason}, {where: {case_id: caseId}});
|
||||||
|
@ -40,6 +40,7 @@ export class SuggestionsSvc {
|
|||||||
})
|
})
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
fetchById = async(id:number)=>await this.model.findByPk(id);
|
fetchById = async(id:number)=>await this.model.findByPk(id);
|
||||||
updateStatus = async(id:number, status:string)=>await this.model.update({status: status}, {where: {id: 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'})
|
create =(userid:string, description:string)=>this.model.create({userid: userid, suggestion: description, status: 'Pending'})
|
||||||
|
@ -50,6 +50,7 @@ export class TagSystemSvc {
|
|||||||
});
|
});
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
async createTag(userid:string, tagName:string, message:string, embedFlag:boolean) {
|
async createTag(userid:string, tagName:string, message:string, embedFlag:boolean) {
|
||||||
CacheServer.delete('tags');
|
CacheServer.delete('tags');
|
||||||
return await this.model.create({userid: userid, tagname: tagName, message: message.replace(/\\n/g, '\n'), embedFlag: embedFlag});
|
return await this.model.create({userid: userid, tagname: tagName, message: message.replace(/\\n/g, '\n'), embedFlag: embedFlag});
|
||||||
|
@ -57,6 +57,7 @@ export class UserLevelsSvc {
|
|||||||
});
|
});
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
fetchEveryone = async()=>await this.model.findAll();
|
fetchEveryone = async()=>await this.model.findAll();
|
||||||
fetchUser = async(userId:string)=>await this.model.findByPk(userId);
|
fetchUser = async(userId:string)=>await this.model.findByPk(userId);
|
||||||
deleteUser = async(userId:string)=>await this.model.destroy({where: {id: userId}});
|
deleteUser = async(userId:string)=>await this.model.destroy({where: {id: userId}});
|
||||||
|
@ -34,6 +34,7 @@ export class YouTubeChannelsSvc {
|
|||||||
})
|
})
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
|
query = async(pattern:string)=>await this.model.sequelize.query(pattern);
|
||||||
async addChannel(YTChannelID:string, DCChannelID:string, DCRole:string) {
|
async addChannel(YTChannelID:string, DCChannelID:string, DCRole:string) {
|
||||||
if (await this.model.findOne({where: {ytchannel: YTChannelID}})) return false;
|
if (await this.model.findOne({where: {ytchannel: YTChannelID}})) return false;
|
||||||
await this.model.create({ytchannel: YTChannelID, dcchannel: DCChannelID, dcrole: DCRole});
|
await this.model.create({ytchannel: YTChannelID, dcchannel: DCChannelID, dcrole: DCRole});
|
||||||
|
Loading…
Reference in New Issue
Block a user