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
|
|
|
}
|