Support Topics Documentation Slack YouTube Blog

One to one relationship

(Rajasekhar Puligadda) #1

can we save multiple 1:1 relation ships once?

(Sergey Chupov) #2

Please see the documentation on setting a relation:
You cannot set a relation while saving a parent object, if that if youre question.

(Rajasekhar Puligadda) #4

For example tables A,B,C
A has 1:N relationship with B after saving data we will get objectId array of B table in return (up to this its fine)

After that B have 1:1 one relation ship, for that i need to implement here for N records of B relation as 1:1 to records of C (multiple one to one relationships)

How we can implement this?

(Sergey Chupov) #5

Effectively you want to update N parents (records from B), which is impossible as of yet. The only option I see is exactly what you seem to already implement - N save requests for each 1:1 relation.

(Rajasekhar Puligadda) #6

so for each 1:1 i need to write then and catch blocks?

(Sergey Chupov) #7

I’m not sure what’s the best option in JS code, in Java I’d do that with a simple for-loop.

(Rajasekhar Puligadda) #8

Yes, In js also for loop we will do each 1:1 relation, for each one we have then and catch blocks