Hello. I have three tables. Preferences, Clients, ...
# orm-help
j
Hello. I have three tables. Preferences, Clients, and clientPreferences. The relation is many-to-many.
Copy code
Preferences {
  id
  ...
}

Clients {
  id
  ...
}

clientPreferences {
  id
  clientId
  preferenceId
}
Now, a preference can be attached/detached to multiple clients. My question is how will I update existing record in
clientPreferences
and at the same time, add a record if it doesn’t exist? My HTTP endpoint for this is
PATCH /preferences/:id
with the JSON request body of
Copy code
{
  "clientIds": [
    1,
    2,
    3
  ]
}