StreamReceiverSeenEventModel.ts
1 import type { 2 InferAttributes, 3 InferCreationAttributes, 4 Sequelize, 5 } from 'sequelize'; 6 import { DataTypes, Model } from 'sequelize'; 7 import type { IEventModel } from '../events/types'; 8 import type { AccountId, BigIntString } from '../core/types'; 9 import getSchema from '../utils/getSchema'; 10 import { COMMON_EVENT_INIT_ATTRIBUTES } from '../core/constants'; 11 12 export default class StreamReceiverSeenEventModel 13 extends Model< 14 InferAttributes<StreamReceiverSeenEventModel>, 15 InferCreationAttributes<StreamReceiverSeenEventModel> 16 > 17 implements IEventModel 18 { 19 declare public receiversHash: string; 20 declare public accountId: AccountId; 21 declare public config: BigIntString; 22 declare public logIndex: number; 23 declare public blockNumber: number; 24 declare public blockTimestamp: Date; 25 declare public transactionHash: string; 26 27 public static initialize(sequelize: Sequelize): void { 28 this.init( 29 { 30 accountId: { 31 allowNull: false, 32 type: DataTypes.STRING, 33 }, 34 config: { 35 allowNull: false, 36 type: DataTypes.STRING, 37 }, 38 receiversHash: { 39 allowNull: false, 40 type: DataTypes.STRING, 41 }, 42 ...COMMON_EVENT_INIT_ATTRIBUTES, 43 }, 44 { 45 sequelize, 46 schema: getSchema(), 47 tableName: 'stream_receiver_seen_events', 48 underscored: true, 49 timestamps: true, 50 indexes: [ 51 { 52 fields: ['accountId'], 53 name: `idx_stream_receiver_seen_events_accountId`, 54 unique: false, 55 }, 56 ], 57 }, 58 ); 59 } 60 }