Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support abstract class codegen. #1

Merged

Conversation

battika
Copy link
Member

@battika battika commented Nov 16, 2020

The idea is to use the generated classes as abstract classes. Custom domain behaviors (i.e. methods, validations, and lifecycles) may be located in another class that inherits the generated model. This could benefit us from

  1. avoiding polluting when running codegen after migration on existing codes.
  2. have lean models without the boilerplates.
  3. share common behaviors across multiple models.

3 new flags:

  • extendAbstractClass - string. Similar to activeRecord that extends BaseEntity. Now it supports custom abstract class inheritance by passing a relative path as string to extendAbstractClass.
  • exportAbstractClass - boolean. Export the generated models as an abstract class without @Entity
  • skipRelationships - boolean. Skip generating relationship columns. Because currently there is a bug from TypeORM failing at foreign key embedded columns in abstract classes.

Close: Kononnable#288

The idea is to use the generated classes as abstract classes. Custom domain behaviors (i.e. methods, validations, and lifecycles) may be located in another class that inherits the generated model. This could benefit us from

1. avoiding polluting when running codegen after migration on existing codes.
1. have lean models without the boilerplates.
1. share common behaviors across multiple models.

3 new flags:

- `extendAbstractClass` - string. Similar to `activeRecord` that `extends BaseEntity`. Now it supports custom abstract class inheritance by passing a relative path as string to `extendAbstractClass`.
- `exportAbstractClass` - boolean. Export the generated models as an abstract class without `@Entity`
- `skipRelationships` - boolean. Skip generating relationship columns. Because currently there is a [bug from TypeORM failing at foreign key embedded columns in abstract classes](typeorm/typeorm#3132).

Close: Kononnable#288
@battika battika merged commit ac7120c into offsite-solutions:master Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use custom abstract class
2 participants