Closed gBasil closed 1 year ago
Not currently, but this is definitely something I want to support. It's a bit long winded, but this could work?
artist::songs::count::order(Direction::Asc)
It may have to be _count
for naming collision reasons but I'll see.
Yeah, that would work for single "layers." But what about if you have a schema like this:
model Artist {
id Int @id @default(autoincrement())
name String
songs Song[]
}
model Song {
id Int @id @default(autoincrement())
name String
artists Artist[]
scrobbles Scrobble[]
}
model Scrobble {
id Int @id @default(autoincrement())
song Song @relation(fields: [songId], references: [id])
songId Int
}
How would you sort the artists based on the number of scrobbles?
Depends how you'd do it in TS, idk if Prisma supports that
True, totally forgot.
Just got this working with the following syntax:
user::posts::order(vec![
post::_count::order(SortOrder::Asc)
])
I'm conflicted on whether I should spend the heap of effort it would take to make it like this:
user::posts::_count::order(SortOrder::Asc)
May be able to at a later update though.
That's wonderful, thank you so much!
Is it currently possible to do something like this?
My actual use-case is for seeing how many scrobbles a certain song has, and it would have another level of ordering―ordering the artists based on the total count of scrobbles across all of their songs.
Thank you for your time!