-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
feat(core): add EntityRepository.getEntityName()
method
#4745
feat(core): add EntityRepository.getEntityName()
method
#4745
Conversation
@@ -286,6 +286,10 @@ export class EntityRepository<T extends object> { | |||
return this._em; | |||
} | |||
|
|||
getEntityName(): EntityName<T> { | |||
return this.entityName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should always return string here? the type could stay the same for better inference support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to return Constructor<T>
, but I understand this is not possible now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know what cases other people will have.
Those who need a string can use Utils.className(this.getRepository().getEntityName())
or we could implement this as an additional proxy method in the EntityRepository
getEntityClassName(): string {
return Utils.className(this.getEntityName())
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to be entity name, so I think a string is actually what most people would expect. While we accept both string name and class reference, the getters should be consistent in what they return.
If you need the class reference, you can always get that from the metadata, e.g. em.getMetadata('Foo').class
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
Please make a new npm version when you have time. I want to test it. Thanks. |
every commit to master is published to npm as dev version |
EntityRepository.getEntityName()
methodEntityRepository.getEntityName()
method
No description provided.