Closed idahogurl closed 5 years ago
Hi @idahogurl ,
It looks like your "states" model is badly configured.
A state
should belongsTo
a country
(instead of hasOne
) if the countryId
foreign key is on the states
table.
If I am right, this is not an issue of the Forest Liana, but a bad configuration on your side.
@arnaudbesnier I have tried belongsTo. Still is not working.
@arnaudbesnier The trick was that I needed to specify foreignKey = "countryId"
and targetKey = "id"
as well as changing to belongsTo
. That would be good to add to your documentation.
Expected behavior
Item is created without error
Actual behavior
Error is given and item is not created
Failure Logs
Terminal Logs Giving Foreign Key error because I do not allow
NULL
incountry_id
in thestates
table.Context
Network Panel is sending the id of the country
Zip of my Models https://www.icloud.com/iclouddrive/0NawNHQCPitC0cdoh91KjEWeQ#models
Video showing steps & error https://youtu.be/7JncXAoVhMI
Package Version: 1.4.1 Express Version: 4.16.3 Sequelize Version: 5.8.11 Database Dialect: MySQL Database Version: 5.7.23