从父母Sequelize那里得到孩子

时间:2016-11-01 12:50:53

标签: sequelize.js

如果我有:

var Game = Sequelize.define('game');
var Move = Sequelize.define('move');
Move.belongsTo(Game);

如何通过所有动作获得一系列游戏?看来我可以通过游戏轻松获得所有动作:

Move.findAll({include: Game});

但不是相反?

Game.findAll({include: Move});

给我Unhandled rejection Error: Move (move) is not associated to game!

1 个答案:

答案 0 :(得分:2)

您需要双向提供关联

Game.hasMany(Move);