I\'m currently experimenting with Sequelize and have two objects, a Person
and Position
, When getting a list of persons I want to get their position. <
From April 2013 in v1.7.0 you need just to expand your Associations to:
Position.hasMany(User, {foreignKey : 'position_id', as: 'User'});
User.belongsTo(Position, {foreignKey : 'position_id', as: 'Posit'});
and then find all Users with associated Positions
User.findAll({
include: [{
model: Position, as: 'Posit'
}]
}).success(function(match) {
// your logic
});