#StackBounty: #sequelize.js Model named "Media" has get/set for "Medium", how to turn off pluralizer

Bounty: 250

Suppose I have a couple models, Media and MediaDerivative.

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);
  };
};

Tables are created named Media and MediaDerivatives as expected. However, the helper functions on a MediaDerivative instance are named as follows:

  • createMedium
  • getMedium
  • setMedium

How can I configure my models such that these are named createMedia, getMedia, and setMedia?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.