Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
TypeORM: ¿cómo usar In() con la relación @ManyToMany?

Tengo dos entidades: Something y Other (los prototipos están abajo).

¿Cómo puedo usar el método In() para encontrar todos los Somethings que tienen Others relacionados por una matriz de ID de Others ?

Necesito algo como esto:

 const smths: Array<Something> = await connection.getRepository(Something).find({ others: In(arrayWithOthersIds), });

Entidades:

 @Entity() class Something { @PrimaryGeneratedColumn('uuid') id: string; @ManyToMany(() => Other, (other) => other.smths, { cascade: true }) others: Other[]; } @Entity() class Other { @PrimaryGeneratedColumn('uuid') id: string; @ManyToMany(() => Something, (smth) => smth.others, { cascade: true }) smths: Something[]; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe usar @JoinTable() desde 1 lado de su relación de muchos a muchos. Además, como sé, no puede usar { cascade: true } en ambos lados, así que elimine uno. Y usa esta consulta:

 const smths: Something[] = await connection .getRepository(Something) .createQueryBuilder('smth') .innerJoin("smth.others", "others") .where('others.id IN (:...ids)', { ids } ) // ids = [1, 2..] .getMany();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!