39 lines
978 B
TypeScript
39 lines
978 B
TypeScript
import { getModelForClass, index, modelOptions, prop } from '@typegoose/typegoose'
|
|
import { dbconn } from 'decorators/dbconn'
|
|
import { BaseModule } from './Base'
|
|
|
|
@dbconn()
|
|
@index({ address: 1 }, { unique: false })
|
|
@index({ transactionHash: 1, from: 1, to: 1 }, { unique: true })
|
|
@modelOptions({
|
|
schemaOptions: { collection: 'check_in_event', timestamps: true },
|
|
})
|
|
export class CheckInClass extends BaseModule {
|
|
@prop({ required: true })
|
|
public from!: string
|
|
@prop()
|
|
public to: string
|
|
@prop({ required: true })
|
|
public hash: string
|
|
@prop()
|
|
public blockNumber: string
|
|
@prop()
|
|
public blockHash: string
|
|
@prop()
|
|
public blockTime: number
|
|
@prop()
|
|
public dateTag: string
|
|
@prop()
|
|
public value: string
|
|
@prop()
|
|
public input: string
|
|
|
|
public static async saveEvent(event: any) {
|
|
return CheckIn.insertOrUpdate({ hash: event.hash }, event)
|
|
}
|
|
}
|
|
|
|
export const CheckIn = getModelForClass(CheckInClass, {
|
|
existingConnection: CheckInClass['db'],
|
|
})
|