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
2024-01-20 23:13:18 +11:00

33 lines
897 B
TypeScript

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();
}
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});
removeWord = async(word:string)=>await this.model.destroy({where: {word: word}})
}