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

313
Views
How to select with conditions in relation in TypeORM?

I want to find row in Friendship, where friendship.friends have users with ids equals to given. How can i do it via Repository and QueryBuilder?

Entities:

import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { UserToFriendship } from "./userToFriendship.entity";

@Entity()
export class Friendship {

    @PrimaryGeneratedColumn()
    id: number

    @OneToMany(() => UserToFriendship, u => u.friendship, {
        eager: true
    })
    friends: UserToFriendship[]

    @Column({ default: false })
    accepted: boolean

}



import { User } from "src/users/entities/user.entity";
import { Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { Friendship } from "./friendship.entity";

@Entity()
export class UserToFriendship {

    @PrimaryGeneratedColumn()
    id: number;

    @ManyToOne(() => User, user => user.friendships)
    user: User;

    @ManyToOne(() => Friendship, friendship => friendship.friends)
    friendship: Friendship;

}
about 4 years ago · Juan Pablo Isaza
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!