TypeORM findOne with nested relations

I am having some issues performing a nested find query with TypeORM. Here’s the basic code:

    const { completionId } = req?.params;
    const user = req.user;

    const retrievedCompletion = await getRepository(
      CompletionGoogleSearch
    ).findOne({
      relations: ['run', 'run.user'],
      where: {
        id: completionId,
        // run: { user: { id: user.id } }, // This is the code that breaks the function
      },
    });

    console.log(retrievedCompletion?.run.user.id);
    console.log(user.id);

It looks to me like there’s nothing out of order, and that the query should run. Any idea on what I am doing wrong? I know I can get around this issue by writing a querybuilder query or using raw SQL–I am just curious to understand if there’s a flaw in my code.

133 thoughts on “TypeORM findOne with nested relations”

  1. Pingback: cialis 10mg india
  2. Pingback: 200 mg sildenafil
  3. Pingback: cialis on line
  4. Pingback: cialis pills india
  5. Pingback: roman sildenafil
  6. Pingback: omnicef mrsa
  7. Pingback: bactrim medscape
  8. Pingback: zithromax medscape
  9. Pingback: augmentin 500mg
  10. Pingback: avelox
  11. Pingback: omnicef pricing
  12. Pingback: augmentin allergy
  13. Pingback: viagra
  14. Pingback: revatio

Leave a Comment