auction-scrapper/app/models/auction.ts
Vakula Uladimir 12f005e335 init
2025-10-17 11:27:52 +03:00

49 lines
1.1 KiB
TypeScript

import { DateTime } from 'luxon'
import { BaseModel, column, hasMany } from '@adonisjs/lucid/orm'
import type { HasMany } from '@adonisjs/lucid/types/relations'
import Notification from '#models/notification'
export default class Auction extends BaseModel {
@column({ isPrimary: true })
declare id: number
@column()
declare auctionNum: string
@column()
declare title: string
@column()
declare description: string | null
@column()
declare organization: string | null
@column()
declare status: string | null
@column()
declare price: number | null
@column.dateTime()
declare deadline: DateTime | null
@column()
declare url: string | null
@column({
prepare: (value: Record<string, any> | null) => (value ? JSON.stringify(value) : null),
consume: (value: string | null) => (value ? JSON.parse(value) : null),
})
declare rawData: Record<string, any> | null
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime
@hasMany(() => Notification)
declare notifications: HasMany<typeof Notification>
}