Hello guys, I have a nested structure of section &...
# orm-help
l
Hello guys, I have a nested structure of section > page > block and I would like to avoid a nested response from prisma to avoid a nested loop in the client that is very slow. I would like to get from prisma 3 arrays like this [section] [page] [block] and I will handle a way to combine in the right order with one loop (or in any case not 3) 🙂
r
@Luca Nigido đź‘‹ The only way to transform this is in your backend then before sending it to the client. Also how many items are you querying for in this case?
l
Now is 20 for a total of 50 and is very slow.
I mean, first level 20, and 50 elements in total
r
Looping over 20*50 i.e. 1000 elements shouldn’t be slow at all. One thing you could do is just return the necessary field via
select
instead of the entire object. Or the option as I mentioned above i.e. transforming the request in the backend before sending it.
l
yes I got it and I will follow both this suggestions. My laptop is very slow in this days probably due to the heat, but any laptop can be slow so I should to the job on the server and give the client data easy to manipulate! And yes, I will exclude unnecessary data! I am wondering how faster will be a nested loop of a javascript object compared to a nested loop that need to pass props and stuff in react!!
Thank you very much ryan!!