sequelize icon indicating copy to clipboard operation
sequelize copied to clipboard

Association functions names can be provided in models

Open anasaijaz opened this issue 3 years ago • 1 comments

Issue Creation Checklist

  • [x] I understand that my issue will be automatically closed if I don't fill in the requested information
  • [x] I have read the contribution guidelines

Feature Description

Associations such as hasMany or belongsToMany right now consider the model name (or alias) to create functions which can get associated data this makes the process a little confusing as you have to sometimes assume the name of the function and test it with alias name or model name. It would be great if while defining the model, names of association functions could be passed

Describe the feature you'd like to see implemented

{
  get: getPicture,
  set: setPictureOfPerson,
  ...
}

Describe why you would like this feature to be added to Sequelize

It eliminates confusion and make associations faster

Is this feature dialect-specific?

  • [x] No. This feature is relevant to Sequelize as a whole.
  • [ ] Yes. This feature only applies to the following dialect(s):

Would you be willing to resolve this issue by submitting a Pull Request?

  • [x] Yes, I have the time and I know how to start.
  • [x] Yes, I have the time but I will need guidance.
  • [ ] No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • [ ] No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.

Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.

anasaijaz avatar Sep 15 '22 16:09 anasaijaz

I don't know if we're going to add such a feature since we're considering changing the system altogether https://github.com/sequelize/sequelize/issues/14302

ephys avatar Sep 17 '22 10:09 ephys

Oh okay! that's even better

anasaijaz avatar Sep 24 '22 08:09 anasaijaz

I'll close in favor of that one then :)

ephys avatar Sep 24 '22 09:09 ephys