i have the following definition:
var Team = sequelize.define('academy_team', {
id: DataTypes.INTEGER,
name: DataTypes.STRING,
academy_id: DataTypes.INTEGER,
is_complete: DataTypes.INTEGER,
started: DataTypes.INTEGER
}, {
freezeTableName: true,
instanceMethods: {
startedTeams: function(onSuccess,onError)
{
Team.findAll({include: [{all: true}], where: {model:academy,division_id: 19 }}, {})
.ok(onSuccess).error(onError);
}
}
}
)
academy = sequelize.define('academy', {
id: DataTypes.INTEGER,
name: DataTypes.STRING,
organization_id: DataTypes.INTEGER,
division_id: DataTypes.INTEGER,
status_id: DataTypes.INTEGER
}, {
freezeTableName: true,
instanceMethods: {
}})
With the following relationship:
Team.belongsTo(academy, {foreignKey: 'academy_id'});
Now as you can see from my (failed) attempt i am trying to select the teams where academy.division_id = 19.
However this does not work
I have also tried the following:
Team.findAll({include: [{all: true}], where: {division_id: 19 }}, {})
.ok(onSuccess).error(onError);
Sadly this produced the following sql:
where academy_team.division_id = 19
Aucun commentaire:
Enregistrer un commentaire