k
r
@kkangsan ๐Ÿ‘‹ You cannot order on the many side of the relation as of now. You need to use a raw query if you need to order on the many type relation. Thereโ€™s a request for this so you can add a ๐Ÿ‘ and follow for more updates: https://github.com/prisma/prisma/issues/5837
๐Ÿ‘ 1
k
@Ryan ๐Ÿ‘‹ Thanks for the reply, In my situation, it's still under development, so changing the field to int seems like the best solution.
r
Itโ€™s not a problem of string or int, you cannot do an order by on
Quiz[]
. If it were
Quiz
then only itโ€™s possible.
Order by on a field of the many side of a relation is not possible.
k
It is my mistake. There seems to be a problem while posting a question by changing from my model to a new example. lesson - quiz 1:1 ๐Ÿ˜…
I just wanted to know how to make the result of sorting for int values โ€‹โ€‹in string field equal to the result of sorting int field.
r
Then sorting should work on strings as well. It will sort based on the alphabets in the string.
k
Is there a way to orderby by casting a string to a number? https://stackoverflow.com/questions/8502505/order-varchar-string-as-numeric
Copy code
select * 
from your_table
order by cast(your_text_column as double precision) desc;
Should I use raw query ?
r
Casting would need a raw query, otherwise you can change your field to a number if thatโ€™s what you want to order by.
๐Ÿ’ฏ 1
๐Ÿ‘ 1
k
@Ryan TY ! ๐Ÿ‘
๐Ÿ™Œ 1
Depending on the type of field, I need to set a column separately or convert it to save it as a number.๐Ÿ‘
๐Ÿ’ฏ 1