0
I am developing a professional register where each professional can speak one or more languages, however when saving professionals, languages are not saved
@Entity('idioma')
export class Idioma {
@PrimaryGeneratedColumn()
id: number;
@Column()
lang: string;
@Column()
native: boolean;
}
@Entity('Profissional')
export class Profissional {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
@IsOptional()
phone: string;
@Column()
@IsOptional()
celPhone: string;
@Column()
@IsOptional()
sexo: string;
@Column()
@IsOptional()
nasc: Date;
@Column('bool')
@IsOptional()
fumante: boolean;
@Column()
@IsOptional()
ocupation: string;
@Column()
@IsEmail()
email: string;
@OneToMany(
() => Idioma,
idioma => idioma.id,
{cascade: true}
)
lang: Idioma[];
@Column()
password: string;
@Column('decimal', { precision: 5 })
latitude: number;
@Column('decimal', { precision: 5 })
longitude: number;
@Column('decimal', { precision: 2 })
@IsOptional()
workPrice: number;
}
async create(profissional: ProfissionalDto) {
const errors = validate(profissional);
profissional.password = bcrypt.hashSync(profissional.password, 12);
const prof = this.profissionalRepository.save(profissional);
return prof;
}