I have model A that can have one or more rows of model B affiliated with it. The relation only has to go one way.
I ran:
result = await A.query()
.where('id', 123) // 123 is an already existing model A
.insertGraph([
{
B: [{id: 456}] // 456 is an already existing model B
}
]);
But I get an error Key (id)=(456) already exists.
To my understanding, Objection is trying to make a new model B with an id 456 where I just want to add a relation between the the two rows A:123 and B:456.