Hello community + team, seeking some advice on how...
# prisma-whats-new
c
Hello community + team, seeking some advice on how to design a schema for a pretty specific use case: I have a 1:N relationship between a
Person
type and a
Reminder
type, where a Reminder has a
notifyDate: DateTime!
field. I want to sort the
Person
type in order of the oldest notifyDate that they have as a reminder, so that the people with the "most expired" reminders are at the top. Currently my solution is to have a field on the person with a DateTime that re-stores the oldest reminder's
notifyDate
, and every time I run a create or update on a Reminder I re-calculate it. Unfortunately, on Graphcool this requires that I add another round-trip query. Any ideas on a better way to structure?
n
@ckelley another approach you could explore is using a Server-Side Subscription on
Reminder(mutation_in: [CREATED, UPDATED])
that recalculates the
notifyDate
of the person
c
@nilan also a great option. This would be asynchronous though, so I'd have to figure out a way to propagate that to the client at some point.
n
That's right! Just thought I bring it up 🙂 A client-side subscription could be used for this, or a simple refresh after a few seconds.