Javascript Sequelize eAger加载错误-Can';我不明白其中包括什么

Javascript Sequelize eAger加载错误-Can';我不明白其中包括什么,javascript,node.js,http,error-handling,sequelize.js,Javascript,Node.js,Http,Error Handling,Sequelize.js,我正在使用sequelize开发Angular和Nodejs构建的应用程序。我建立了一个用户模型,作为发送者有许多通知,作为接收者有许多通知。通知模型也属于作为发送者的用户和作为接收者的用户。我的问题是,当我尝试在通知上实现GET http请求时,我收到一个Sequelize急切加载错误。我已经注释掉了include语句,以及user上的notifications属性,GET请求可以正常工作。我只是不明白是什么导致了这个错误 这是我的模型 “严格使用” 这是我的通知控制器,它保存通知路由的逻辑

我正在使用sequelize开发Angular和Nodejs构建的应用程序。我建立了一个用户模型,作为发送者有许多通知,作为接收者有许多通知。通知模型也属于作为发送者的用户和作为接收者的用户。我的问题是,当我尝试在通知上实现GET http请求时,我收到一个Sequelize急切加载错误。我已经注释掉了include语句,以及user上的notifications属性,GET请求可以正常工作。我只是不明白是什么导致了这个错误

这是我的模型

“严格使用”

这是我的通知控制器,它保存通知路由的逻辑

list: function list(req,res) {
    var decoded = jwt.decode(req.query.token);
    return model.User.findOne({
      where: {id: decoded.user.id},
      include: [{
        model: model.Notification
      }]
    }).then(function (user) {
        let ratingAv;
        for (let rating of user.ratings) {
          ratingAv = (user.ratings.length/(rating += rating)*10);
        }
        console.log(ratingAv + ' RATINGSSSS');
        let resObj = Object.assign({}, {
          id: user.id,
          profileImgUrl: user.profileImgUrl,
          fName: user.fName,
          lName: user.lName,
          yearOfBirth: user.yearOfBirth,
          gender: user.gender,
          ratings: ratingAv,
          notifications: user.Notifications.map(function(notification) {
            return Object.assign({}, {
              id: notification.id,
              startAddress: notification.startAddress,
              endAddress: notification.endAddress,
              tripDate: notification.tripDate,
              tripHour: notification.tripHour,
              numberOfPassengers: notification.numberOfPassengers,
              price: notification.price,
              senderId: notification.senderId,
              receiverId: notification.receiverId
            });
          })
        });
      return res.status(201).json({
        message: 'Notifications retrieved successfully',
        obj: resObj
      });
    }).catch(function (err) {
      return res.status(400).json({
        title: 'There was an error retrieving notifications',
        error: err
      });
    });
  },

如果我能得到一个更好的错误,我就能找出它。该错误非常普遍,无法帮助我理解可能拼写错误、放置错误等。有人能找出问题所在吗?

我的include选项中缺少as:参数。如果在同一个模型上使用同一模型的多个实例(作为用户,通知时同时作为用户),则需要使用别名来使用include:上的as:选项标识它们。祝你好运

list: function list(req,res) {
    var decoded = jwt.decode(req.query.token);
    return model.User.findOne({
      where: {id: decoded.user.id},
      include: [{
        model: model.Notification
      }]
    }).then(function (user) {
        let ratingAv;
        for (let rating of user.ratings) {
          ratingAv = (user.ratings.length/(rating += rating)*10);
        }
        console.log(ratingAv + ' RATINGSSSS');
        let resObj = Object.assign({}, {
          id: user.id,
          profileImgUrl: user.profileImgUrl,
          fName: user.fName,
          lName: user.lName,
          yearOfBirth: user.yearOfBirth,
          gender: user.gender,
          ratings: ratingAv,
          notifications: user.Notifications.map(function(notification) {
            return Object.assign({}, {
              id: notification.id,
              startAddress: notification.startAddress,
              endAddress: notification.endAddress,
              tripDate: notification.tripDate,
              tripHour: notification.tripHour,
              numberOfPassengers: notification.numberOfPassengers,
              price: notification.price,
              senderId: notification.senderId,
              receiverId: notification.receiverId
            });
          })
        });
      return res.status(201).json({
        message: 'Notifications retrieved successfully',
        obj: resObj
      });
    }).catch(function (err) {
      return res.status(400).json({
        title: 'There was an error retrieving notifications',
        error: err
      });
    });
  },