typeorm-fixtures
typeorm-fixtures copied to clipboard
[Question] Relation ManyToMany fixture
Hello,
I'm trying to do a relation @ManyToMany between two different entities. The code seems to be fine. The problem is in my fixture, when I try to do the relation I can't get the data in my database like it should be.
ProfileDataModel :
@Entity({ name: "profileData" })
export class ProfileDataModel extends BaseModel {
@ManyToMany((): ObjectType<TagModel> => TagModel, (tag: TagModel): ProfileDataModel => tag.profileData, { eager: true } )
@JoinTable({name: "relationProfilesTags"})
tags: TagModel[];
}
TagModel :
@Entity({ name: "tag" })
export class TagModel extends BaseModel {
@ManyToMany((): ObjectType<ProfileDataModel> => ProfileDataModel, (profileData: ProfileDataModel): TagModel[] => profileData.tags)
profileData: ProfileDataModel;
}
ProfileDataFixture :
entity: ProfileDataModel
items:
UnusedProfile:
id: "3965dbb3-6018-4491-b9ae-585807c11578"
tags:
- "@Cinema"
TagFixture :
entity: TagModel
items:
Cinema:
id: "653fceb8-eba6-4cd2-b340-0b074ba09e1a"
name: "Cinéma"
Thanks for your help and your time :)