sequelize-typescript-generator
sequelize-typescript-generator copied to clipboard
feat: add support for association methods
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 lintbut 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
- I ran
> [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.
- I can run the tests and they all pass, but wasn't sure where to add testing for the new functionality. I looked into
-
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?
It seems it also breaks when supplying -C arg