sequelize-typescript
sequelize-typescript copied to clipboard
Association Error
I have this
@Table({
tableName: "peso_productos"
})
export class PesoProducto extends Model<PesoProducto> {
@ForeignKey(() => Vendedor)
@Column
vendedor_id: number;
@BelongsTo(() => Vendedor, "vendedor_id")
vendedor: Vendedor;
}
Vendedor side:
@Table({
tableName: "vendedores"
})
export class Vendedor extends Model<Vendedor> {
@HasMany(() => PesoProducto)
pesoProductos: PesoProducto[];
}
And just initializing sequelize throws this error
SequelizeAssociationError: You have used the alias vendedor in two separate associations. Aliased associations must have unique aliases.
What I'm doing wrong?
I just figured out what was happening, I was initializing sequelize twice. You can close this issue guys and btw great library 👍