【发布时间】:2022-01-16 22:11:42
【问题描述】:
问题是有时某个特定的列无故变为空或null,该列是“link_status”,按照下面的代码。
"typeorm": "^0.2.40"
useFactory: async () =>
await createConnection({
type: 'mysql',
host: process.env.DB_HOST,
port: 3306,
username: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_DATABASE,
entities: [Link, LinkPayment, LinkPaymentStatus, LinkItems],
synchronize: true,
}),
@Entity('link')
export class Link extends BaseEntity {
@PrimaryGeneratedColumn()
link_id: number
@Column()
patient_id: number
@Column({ length: 9 })
link_status: string
@Column({ length: 45 })
token: string
@Column({ length: 100 })
link_url: string
@Column()
created_at: Date
@Column()
expiry_at: Date
@Column()
updated_at: Date
}
【问题讨论】:
-
您使用的是
synchronize: true,这就是原因。我不知道为什么它会变成空或 null,tbh -
@MicaelLevi 这就是问题所在,同步不会仅对他的其他列执行此操作
-
这可能是一个错误。 Typeorm 有很多错误:/
标签: nestjs typeorm node.js-typeorm