Added support for include relationship alias (as) and nested includes, fixed wrong joi json validation implementation inside parseInclude() function, fixed some associated routes resulted 404 because of prefix option
This commit is contained in:
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
export default (sequelize, DataTypes) => {
|
||||
return sequelize.define('Master', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
}, {
|
||||
classMethods: {
|
||||
associate: (models) => {
|
||||
models.Master.hasMany(models.Player, {
|
||||
foreignKey: 'coachId'
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
Vendored
+4
@@ -14,6 +14,10 @@ export default (sequelize, DataTypes) => {
|
||||
models.Player.belongsTo(models.Team, {
|
||||
foreignKey: { name: 'teamId' },
|
||||
});
|
||||
models.Player.belongsTo(models.Master, {
|
||||
foreignKey: 'coachId',
|
||||
as: 'Coach',
|
||||
});
|
||||
},
|
||||
},
|
||||
scopes: {
|
||||
|
||||
Reference in New Issue
Block a user