TypeORM delete using WHERE with OR operator using Repository

Viewed 4586

I have a Repository class with which I would like to delete Entities in my database using the inherited method repository.delete() based on 2 conditions combined via the OR operator.

I would to achieve something like that:

deleteAllAboOfUser(userId: string): Promise<DeleteResult> {
        return this.delete([
            { followerId: userId},
            {followingId: userId}
        ]);
    }

And the generated SQL should look like the following:

DELETE FROM subscription WHERE follower_id = 'xxxx' OR following_id = 'xxxx';

But it seems to be impossible currently to uses the OR condition for the delete, but only the AND.

1 Answers

Checked documentation of a repository API and found that there is no provision to delete based on the OR operator.

I think you need to use the query builder to achieve this.

Related