【发布时间】:2021-04-07 08:03:56
【问题描述】:
我正在尝试发出GET 请求。我有一个主要的Article 实体和一个ArticleContent 实体。我不知道连接有什么问题。当我试图取回之前创建的实体时,ArticleContent 列是 null(它应该是 ArticleContent 的 id)。
这是Article:
@Entity('article')
export class Article extends DefaultEntity {
@Column({ type: 'integer', default: 0 })
numberOfViews: number;
@Column({
type: 'enum',
enum: ArticleType,
default: ArticleType.BLOG,
})
type: ArticleType;
@OneToOne(() => ArticleContent, { cascade: true, eager: true })
@JoinColumn()
content: ArticleContent;
}
ArticleContent:
@Entity({ name: 'article_content' })
export class ArticleContent extends DefaultEntity {
@Column({ type: 'text' })
title: string;
@Column({ type: 'text', nullable: true })
summary: string;
@Column({ type: 'text', nullable: true })
description: string;
}
我如何提出POST 请求:
{
"numberOfViews" : "13",
"type:" : "NEWS",
"content" : [{
"title" : "TEST"
}]
}
GET 请求后我看到的内容:
"content": null
【问题讨论】:
标签: typescript postgresql typeorm