question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

populate against existing entities

See original GitHub issue

When writing business logic that is something like:

processChildren(children: Child[]): Promise<void> {
  await Promise.all(children.map(async child => {
    const parent = await child.parent.load()
  });
});

I’ve got an N+1 loading the parent for each child. I’d like to do something like populate: { parent } but that only works if I’m the one who loaded the children / i.e. called find.

Would it be easy/possible to add a populate method directly to EntityManager, i.e.:

em.populate(children, ["parent"]);

?

Or is there an existing/better way to do this that I’m missing?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
B4nancommented, Jan 22, 2020

I don’t want to change the EntityLoader signature now (BC), but we can add that new method to EM that would work like this.

0reactions
stephenhcommented, Jan 28, 2020

This is great, thanks @B4nan !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Populate an existing entity from a new data source
Populate an existing entity from a new data source · Create new Integration and Source content packs. · Use the existing Target entity...
Read more >
Entity Framework: Populate existing object instance
The closest you'll be able to get is to use DbEntityEntry.Reload on your entity object, followed by using the DbEntityEntry.Reference and DbEntityEntry.
Read more >
Smart Nested Populate
To populate existing entities, you can use em.populate() . const authors = await em.
Read more >
Data Integration. How to load into existing entity
We use SQL server data source through data gateway. I can query my on-prem dataset and would like to load my list if...
Read more >
Auto-Populate fields on new entities from multiple...
You can try field mapping / relationship mapping.. but in relationship mapping you can populate only from one entity and datatype/ length of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found