import { Table, Column, AllowNull, DataType, Model, Default, } from 'sequelize-typescript' export interface TweetData { username: string statusId: string url: string cleanHTML: string body: object order: number } @Table({ modelName: 'tweet', indexes: [ { fields: ['statusId'], unique: true, }, ], }) export default class Tweet extends Model { @AllowNull(false) @Column(DataType.CHAR(255)) get username(): string { return this.getDataValue('username') } @AllowNull(false) @Column(DataType.CHAR(30)) get statusId(): string { return this.getDataValue('statusId') } @AllowNull(false) @Column(DataType.TEXT) get url(): string { return this.getDataValue('url') } @AllowNull(false) @Column(DataType.TEXT) get cleanHTML(): string { return this.getDataValue('cleanHTML') } @AllowNull(false) @Default(false) @Column(DataType.BOOLEAN) get disabled(): boolean { return this.getDataValue('disabled') } @AllowNull(false) @Column(DataType.JSON) get body(): object { return this.getDataValue('body') } @AllowNull(false) @Default(0) @Column(DataType.INTEGER.UNSIGNED) get order(): number { return this.getDataValue('order') } getData(): TweetData { return { username: this.username, statusId: this.statusId, url: this.url, cleanHTML: this.cleanHTML, body: this.body, order: this.order, } } }