I have this Product model with multiple relations to the Lookup model:
```
// Product model
@BelongsTo(() => Lookup, 'LkpCountyOid')
county: Lookup;
@BelongsTo(() => Lookup, 'LkpStateOid')
state: Lookup
@Column
LkpCountyOid: number;
@Column
LkpStateOid: number;
```
Example query:
const productData = await Product.find({
include: [
{ model: Lookup, as: "LkpStateOid"}
]
});
My understanding from the docs and this issue is that the "as" property should allow for multiple relations.
Here is the error I'm getting:
SequelizeEagerLoadingError: Lookup is associated to Product multiple times. To identify the correct association, you must use the 'as' keyword to specify the alias of the association you want to include.
Thanks in advance for your help!
Hey @dlemburg you need to use the property name of the related model instead of the foreign key for as. { model: Lookup, as: "state"}.
Ah, excellent. Thank you for the quick response and great library!
Most helpful comment
Hey @dlemburg you need to use the property name of the related model instead of the foreign key for
as.{ model: Lookup, as: "state"}.