Javascript Can';t更新关系n:m
我有两个与n:m有关的实体Javascript Can';t更新关系n:m,javascript,node.js,typeorm,Javascript,Node.js,Typeorm,我有两个与n:m有关的实体 @ObjectType() @Entity("tags") export class TagEntity extends BaseEntity { @Field(() => ID) @PrimaryGeneratedColumn() id: number; @Field(() => [PostEntity]) @ManyToMany(() => PostEntity, post => post.tags) posts:
@ObjectType()
@Entity("tags")
export class TagEntity extends BaseEntity {
@Field(() => ID)
@PrimaryGeneratedColumn()
id: number;
@Field(() => [PostEntity])
@ManyToMany(() => PostEntity, post => post.tags)
posts: PostEntity[];
}
当我尝试使用新标记发出错误更新post时:
关系“posts”的“postsId”列不存在
更新逻辑:
await this.postsRepository.update({ id }, postData);
postData:
{ id: '1',
title: 'new post title',
url: 'new post url',
tags:
[ TagEntity {
id: 2,
title: 'tag title 2',
url: 'tag url 2',
createdAt: 2019-03-04T08:56:50.531Z,
updatedAt: 2019-03-04T08:56:50.531Z } ] }
生成的sql:
UPDATE“posts”设置“id”=$2,“title”=$3,“url”=$4,“postsId”=$5,“updatedAt”=当前时间戳,其中“id”=$1--参数:[“1”,“1”,“新帖子标题”,“新帖子url”,null]
{ id: '1',
title: 'new post title',
url: 'new post url',
tags:
[ TagEntity {
id: 2,
title: 'tag title 2',
url: 'tag url 2',
createdAt: 2019-03-04T08:56:50.531Z,
updatedAt: 2019-03-04T08:56:50.531Z } ] }