Prisma not creating entries in the given order

I have the following trpc prisma code given below. When "module" have the optional "image" field filled it will be created after all the empty ones even though the request has them in an array where they are ordered. Any idea on how to fix it? Sorry for the long code Output: Got modules as: [ '<p>1</p>', '<p>2</p>', '<p>3</p>', '<p>4</p>' ] Created modules as: [ '<p>2</p>', '<p>3</p>', '<p>4</p>', '<p>1</p>' ] Code:
3 Replies
Keef
Keef16mo ago
Idk what they do under surface but it’s probably because the future (creating the entry for the module) with the image is probably taking longer then the others which is why it’s “out of order”. I don’t think sql guarantees order but either way it’s correct. If you want them ordered by some property you should be ordering them in the query and not hoping the promises resolve themselves correctly Also you probably shouldn’t be calling the prisma disconnect explicitly unless you know what you are doing The protected procedure should probably be checking for session already so the if guard is also likely unnecessary
thevalorised
thevalorised16mo ago
Thank you!
Keef
Keef16mo ago
ferrisHeartEyes
Want results from more Discord servers?
Add your server