Fixing monitors to have proper createdAt
This commit is contained in:
parent
9e9b0194da
commit
25fb2c9bdc
2 changed files with 2 additions and 2 deletions
|
|
@ -19,7 +19,6 @@ export class Monitor {
|
||||||
|
|
||||||
@Column('datetime', {
|
@Column('datetime', {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
default: dayjs(),
|
|
||||||
transformer: {
|
transformer: {
|
||||||
to: (value?: Dayjs) => (value ?? dayjs()).format(),
|
to: (value?: Dayjs) => (value ?? dayjs()).format(),
|
||||||
from: (value: Date) => dayjs(value),
|
from: (value: Date) => dayjs(value),
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'
|
||||||
import { InjectRepository } from '@nestjs/typeorm'
|
import { InjectRepository } from '@nestjs/typeorm'
|
||||||
import { Repository } from 'typeorm'
|
import { Repository } from 'typeorm'
|
||||||
|
|
||||||
|
import dayjsTz from '../common/dayjs'
|
||||||
import { Monitor, MonitorType } from './entity'
|
import { Monitor, MonitorType } from './entity'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
@ -13,7 +14,7 @@ export class MonitorsService {
|
||||||
|
|
||||||
async performMonitor(type: MonitorType, data: string) {
|
async performMonitor(type: MonitorType, data: string) {
|
||||||
await this.monitorsRepository.save(
|
await this.monitorsRepository.save(
|
||||||
this.monitorsRepository.create({ type, data }),
|
this.monitorsRepository.create({ type, data, createdAt: dayjsTz() }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue