sequelize-typescript-generator icon indicating copy to clipboard operation
sequelize-typescript-generator copied to clipboard

feat: add support for association methods

Open jsindos opened this issue 1 year ago • 1 comments

This PR adds support for sequelize association methods, as per

  • https://github.com/sequelize/sequelize/issues/14637
  • https://sequelize.org/docs/v6/other-topics/typescript/

For example, when providing the association csv, we will also get the following properties added (from the person <-> passport test data):

    declare getPassport: HasOneGetAssociationMixin<passport>;

    declare setPassport: HasOneSetAssociationMixin<passport, number>;

    declare createPassport: HasOneCreateAssociationMixin<passport>;

Note the following hasn't been added / run:

  • linting
    • I ran npm run lint but get the following output, wondering if I can get some help on how to run automatic eslint fix on my changes using the project configuration
> [email protected] lint
> eslint --fix --ext .ts output/*.ts


Oops! Something went wrong! :(

ESLint: 8.57.0

No files matching the pattern "output/*.ts" were found.
Please check for typing mistakes in the pattern.
  • tests

    • I can run the tests and they all pass, but wasn't sure where to add testing for the new functionality. I looked into it('1:1', async () => { but it seems these tests are on the Sequelize models themselves, rather than the generated types.
  • import statements

    • The import statements for the new Mixins are always added, should these instead be added conditionally or will linting clean this up automatically?

jsindos avatar Oct 30 '24 05:10 jsindos

It seems it also breaks when supplying -C arg

jsindos avatar Oct 30 '24 05:10 jsindos