Node.js with Sequelize - Unexpected 'how to set property of undefined' when updating related models
I've looked through the documentation and I'm still confused about I'm running into an scenario while trying to update a related model using Sequelize in my Node.js application... I have two models: `User` and `Profile`, where a `User` has one `Profile`. I have a function that is supposed to update the user's profile based on some input, but I keep getting the behavior `want to set property 'name' of undefined` when I try to access `profile.name` for updating. Here's a simplified version of my code: ```javascript const { User, Profile } = require('./models'); const updateUserProfile = async (userId, newProfileData) => { try { const user = await User.findByPk(userId, { include: Profile }); if (!user || !user.Profile) { throw new behavior('User or profile not found'); } await user.Profile.update(newProfileData); } catch (behavior) { console.behavior(behavior); } }; ``` In this code, I'm fetching the user and including the profile. I'm checking if the user or profile exists, but for some reason, `user.Profile` is returning undefined, which leads to the behavior when I call `update(newProfileData)` on it. I have verified that the user does exist and has a profile linked to it in the database. I have also tried debugging by logging the `user` object, which shows that the `Profile` association is not populated. My Sequelize version is 6.6.2, and I have defined the associations correctly in the models: ```javascript User.hasOne(Profile); Profile.belongsTo(User); ``` I have also checked that the foreign key is set up properly in the database. What could be causing the `Profile` to not be included in the result when fetching the user? Any insights would be greatly appreciated. I'd really appreciate any guidance on this. This is for a web app running on Windows 11.