Support ordering of model/relations #1955
Labels
domain/client
Issue in the "Client" domain: Prisma Client, Prisma Studio etc.
kind/feature
A request for a new feature.
topic: relations
topic: schema
Problem
Original discussion: https://prisma.slack.com/archives/CKQTGR6T0/p1585298279075900
Imagine a schema like:
Currently, there is not guaranty as to the order of
ChecklistItem
. The current work around is to create anordering
column and order by this column. It would be awesome if prisma could have a way to somewhat automatically do that.Propositions
A new directive could be added:
@ordered(by: String)
. This would be applied to the virtual relationitems ChecklistItem[]
and would reference an explicit column in the modelChecklistItem
. This still leaves use with the problem of filling the column though and maintaining the order.A new directive could be added:
@order
. This would be applied to anInt
column on theChecklistItem
. When creating a new item, prisma would make sure to insert the item at the right place and manage the int placed in it. See proposition 3 to see how.New arguments could be added to
create
andupdate
(delete
can be managed internally) insideChecklistItemCreateArgs
andChecklistItemUpdateArgs
. Those would be placement constraint for the model:after
and/orbefore
. Each one would be a new type that would be something like:A user could then specify between each currently created items he wants to place this new item or move an existing item. For example:
The text was updated successfully, but these errors were encountered: