-
Notifications
You must be signed in to change notification settings - Fork 352
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
Allow for Better Inheritance and Extendability of Generated Entity Models #1373
Comments
this
in static methods instead of className
to enable for better inheritance and extendability of Models
Interesting idea, our models are autogenerated so we would need to make sure that we don't overwrite the extended definitions |
@filo87, it seems like you have a good understanding of this problem. If you would like to make a PR we would happily add the feature. |
Ok great will prepare a PR for this |
Not much to change, only in the ejs model template:
this should already do the job! I quickly tried the template in my project and was OK...what additional testing is required? |
Close this now, pr merged |
It would be great to be able to extend the definitions of generated models (from
yarn codegen
) and instantiate sub-classes with enhanced functionalities and logic by still maintaining the methods of the original parent Entity (like save(), get(), ...).As an example, given a generated model Entity
Account
it should be possible to do something like this:for this purpose, all static methods returning an instance of the model Entity class should call the constructor and their own static methods as
this
and NOT asclassName
.here some examples:
subql/packages/cli/src/template/model.ts.ejs
Line 42 in b0f0bbc
subql/packages/cli/src/template/model.ts.ejs
Line 66 in b0f0bbc
The text was updated successfully, but these errors were encountered: