Simultaneously add and remove multiple many-to-many relation entries using TypeORM

13 views Asked by At

I am developing an application backend in typescript using NestJS, TypeORM and Postgres.

My (simplified) data model is as follows: I have a task entity and a user entity. One task can be assigned to any number of users. This is represented by a many-to-many relation.

I need an API endpoint which updates the list of assignees for any task. The endpoint receives an array of user IDs to be set as the task assignees.

Is it possible to do so in a single query? If it is, how would I do so?

If it isn't, is there an alternative way I could implement something functionally equivalent with decent performance?

0

There are 0 answers