Order relation array? #22561
Order relation array?
#22561
-
Beta Was this translation helpful? Give feedback.
Answered by
janpio
Apr 29, 2024
Replies: 1 comment 2 replies
-
Hello @conduongtong 👋 I don't believe it's possible without using the order field. Which database are you using? const orderedIds = [2, 1, 3]; // The desired order of IDs
const result = await prisma.$queryRaw`SELECT * FROM Post WHERE id IN (${Prisma.join(orderedIds)}) ORDER BY FIELD(id, ${Prisma.join(orderedIds)})`; Reference for $queryRaw. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related issue opened by @conduongtong: #23898