I have a scenario where a I need to persist complex Entity with OneToMany, ManyToMany and nested relations.
Until now, .save() has come handy, but now that I need to persist a quite big amount of related resources, performance is just not acceptable. Before doing handmade chunk saves and stuff, I'd like to give it a try to inser(), but according to the docs this performs a primitive (and efficient) INSERT query, but does not take care of the relationships.
Has anyone faced this scenario? How did you approached adding the required Id for all the related resources?
Let's say I have a FatherEntity, just and instance of that class
const rootEntity = {
name: 'tomas'
someNtoNRelation : [{data}, {data}..]
childs: [
{ name: 'michael',
childs: [ { name: 'john'
childs: [{moreData}]
}
]
}
]
anotherNToNRelation: [{data}, {data}..]
}
How woudl you use insert() here, or how would you approach this scenario, taking in account that there can be LOTS of elements in the relations?
Thanks a lot