Skip to content

Implemented entity factory to create entities - #3910

Merged
pleerock merged 1 commit into
typeorm:nextfrom
nicomouss:entity-factory
Mar 29, 2019
Merged

pleerock merged 1 commit into
typeorm:nextfrom
nicomouss:entity-factory

Conversation

@nicomouss

Copy link
Copy Markdown

Following PR #3845

  1. Refactored the code to use an EntityFactory to create the entities
  2. Added optional "entityFactory" configuration option: this gives full flexibility to end-user to fine-tune how the entities are created by the ORM (for example he might want to stay with previous behaviour when entities are creating by calling the constructor). Default behaviour stays the one implemented in PR Skip constructor when entity is loaded from database #3845 (skipping constructor).

Also using a custom entity factory, end-user can now use ES6 Proxy API to profile the entities created by the ORM.

See examples implemented as tests in the PR.

@pleerock
pleerock merged commit 20ff8c6 into typeorm:next Mar 29, 2019
@pleerock

Copy link
Copy Markdown
Member

Looks good. Can we have some docs for that too?

@nicomouss

Copy link
Copy Markdown
Author

Yes will try to document this soon, should I create another PR for that?

@nicomouss
nicomouss deleted the entity-factory branch April 4, 2019 15:56
@Kononnable

Copy link
Copy Markdown
Contributor

This PR is merged, so yes - another PR.
I wonder if we should add 'old EntityFactory` and export it from typeorm to make it easier to migrate if someone was using property initialization in models.

@nicomouss

Copy link
Copy Markdown
Author

I agree with Old Entity Factory. Should we find another more meaningful name for it?
For now, everything implemented in PR #3962

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants