ATC_SIMPLE/BACKEND/app/models/line.ts

43 lines
911 B
TypeScript

import { DateTime } from 'luxon'
import { BaseModel, belongsTo, column, hasMany } from '@adonisjs/lucid/orm'
import type { BelongsTo, HasMany } from '@adonisjs/lucid/types/relations'
import Station from './station.js'
import Log from './log.js'
export default class Line extends BaseModel {
@column({ isPrimary: true })
declare id: number
@column()
declare port: number
@column()
declare lineNumber: number
@column()
declare lineClear: number
@column()
declare stationId: number
@column()
declare apcName: string
@column()
declare outlet: number
@belongsTo(() => Station)
declare station: BelongsTo<typeof Station>
@hasMany(() => Log, {
foreignKey: 'lineId',
})
declare logs: HasMany<typeof Log>
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime
}