Skip to content

populate against existing entities #310

@stephenh

Description

@stephenh

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions