Sequelize include 不适用于 hasOne 关系

Sequelize include is not working with hasOne relationship

嗨,我有一个 User 模型和一个 ProfilePicture 模型。用户只能有1张头像,一张头像只能属于一个用户。

我的问题是在我的获取请求中我正在调用个人资料图片模型并包括用户模型,我得到的只是我的个人资料图片而没有我的用户对象。

User.hasOne(pp,
    { foreignKey: "userId" }
);

pp.belongsTo(User,
    { foreignKey: "userId" }
);

router.get(
    "/pp",
    auth,
    async (req, res) => {
        let { id } = req.user;

        await pp.findOne({
            where: {
                userId: id
            }
        },
        {
            include: [{
                model: User,
            }]
        }).then((user) => {
            console.log(user)
                
            if (!user)
                return res.status(404).send();

            res.send(user);
        });
    });

您需要在第一个参数中包含 include

await pp.findOne({
  where: {
    userId: id
  },
  include: [
    {
      model: User
    }
  ]
});