Matheus Assis
02/10/2022, 1:24 PMcreateMany
doesn't allow us to create the relations. What I'm doing is to first call createMany
for the "base" write, and then I get the recently created ids with findMany
and then call createMany
again for each of the relations. The problem with this is that if some of the relations fail, the previous writes still exists. So I need to manually delete them in this case, and even this is not perfect, because while one of the elements on the createMany may have failed, not all of them would.
I was planning on using a transaction but I saw that it doesn't help me in this case. What would be the best practice to do this then? Manually loop through each record and use nested write instead, and not do batches with createMany? But then it'd take a looong time instead. Is there a different solution?Austin Zentz
02/10/2022, 1:37 PMAustin Zentz
02/10/2022, 1:37 PMMatheus Assis
02/10/2022, 2:04 PMMatheus Assis
02/10/2022, 2:05 PMAustin Zentz
02/10/2022, 2:36 PM