Skip to content

Commit

Permalink
feat(core): add EntityRepository.getEntityName() method (#4745)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscon committed Sep 25, 2023
1 parent 280733f commit 47bfedd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/entity/EntityRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ export class EntityRepository<T extends object> {
return this._em;
}

getEntityName(): string {
return Utils.className(this.entityName);
}

/**
* Returns the underlying EntityManager instance
*/
Expand Down
4 changes: 4 additions & 0 deletions tests/EntityRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@ describe('EntityRepository', () => {
expect(() => repo.assign(e, {})).toThrowError(`Trying to use EntityRepository.assign() with 'Author' entity while the repository is of type 'Publisher'`);
});

test('getEntityName() returns the correct value', async () => {
expect(repoMongo.getEntityName()).toEqual(Publisher.name);
});

});

0 comments on commit 47bfedd

Please sign in to comment.