假设我有两个模型,media和mediadrivative。
module.exports = (sequelize, DataTypes) => {
const Media = sequelize.define('Media', {
// fields
});
Media.associate = (models) => {
Media.hasMany(models.MediaDerivative);
};
};
module.exports = (sequelize, DataTypes) => {
const MediaDerivative = sequelize.define('MediaDerivative', {
// fields
});
MediaDerivative.associate = (models) => {
MediaDerivative.belongsTo(models.Media);
};
};
创建的表名为
Media
和
MediaDerivatives
如预期。但是,helper在
MediaDerivative
实例命名如下:
-
createMedium
-
getMedium
-
setMedium
如何配置我的模型以使它们命名
createMedia
,请
getMedia
,和
setMedia
是吗?