在保存关系方面遇到麻烦。我试图创建一个用户并传递电话号码数组(字符串类型)
按照我提供的方式,在中间件类型或参数phoneNumbers [0]中显示为字符串。这是我的实体的外观,
@Description('A user has multiple phone numbers')
@OneToMany(() => PhoneNumber, phoneNo => phoneNo.user, { nullable: true })
phoneNumbers: PhoneNumber[] | string[];
@Description('Ids of user\'s phone number')
@RelationId((user: BaseUser) => user.phoneNumbers)
phoneNumberIds: number[];
@Entity()
export class PhoneNumber extends BaseEntity {
@Description('10 digit phone number of user')
@Column('text')
@Required()
number: string;
@Description('Weather this number is primary contact number of user or not')
@Column('boolean')
isPrimary: boolean;
@Description('Many phone numbers are assosiated to a single user')
@ManyToOne(() => BaseUser, user => user.phoneNumbers)
user: BaseUser;
@Description('Owner user\'s id')
@RelationId((number: PhoneNumber) => number.user)
userId: number; ```
Unable to identify the cause of facing this error
{ AJV_VALIDATION_ERROR: At BaseUser.phoneNumbers[0], value '090078602123' should be object...}