Hey guys, I have a quick Q - brain is a little fri...
# orm-help
m
Hey guys, I have a quick Q - brain is a little fried. I have two tables with a one-to-many relationship. For eg... Table 1 (parent): name, age, children Table 2 (children) name, age, favourite_number parent_id How can I update table 1 to set parent_id on table 2 when the request sends a parent object with an array of children, and remove it from any existing children if it wasn't in the request array. eg: { name: "Parent name", age: 30, children: { name: "Child name", age: 12, favourite_number: 4 } Should set that childs parent_id to the parents ID, and any other entry in the children table that may have had that parents ID to null Hope that's clear...
r
@Moh 👋 You can use
set
for this as shown here.