无法在Sequelize中添加依赖项

时间:2013-11-30 20:32:55

标签: mysql node.js dependencies has-one sequelize.js

使用node.js和Sequelize.js

在MySQL中有两个表:

设备

  • ID
  • 名称
  • ...

device_track

  • ID
  • DEVICE_ID
  • ...

如何在两个表之间添加依赖关系?

//include models
Device_track.hasOne(Device,{ foreignKey: 'device_id'})
Device_track.findAll({limit:1}).success(function(projects) {
    for (var k in projects)
    {
        console.log(projects[k].dataValues);
        console.log(projects.getDevice()); //or .getDevices returns error (method not found)
        console.log("\n");
    }
})

0 个答案:

没有答案