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

33 lines
897 B
TypeScript
Raw Normal View History

2023-12-24 10:21:40 -05:00
import DatabaseServer from '../components/DatabaseServer.js';
import {Model, DataTypes} from 'sequelize';
class prohibitedWords extends Model {
declare public word: string;
}
export class ProhibitedWordsSvc {
private model: typeof prohibitedWords;
constructor() {
this.model = prohibitedWords;
this.model.init({
word: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
primaryKey: true
}
}, {
tableName: 'prohibitedwords',
createdAt: false,
updatedAt: false,
sequelize: DatabaseServer.seq
})
this.model.sync();
}
2024-01-16 06:41:30 -05:00
findWord = async(word:string)=>await this.model.findByPk(word);
2024-01-16 06:28:03 -05:00
getAllWords = async()=>await this.model.findAll();
insertWord = async(word:string)=>await this.model.create({word: word});
removeWord = async(word:string)=>await this.model.destroy({where: {word: word}})
2023-12-24 10:21:40 -05:00
}