Hello,
I am designing a notification system where each notification is a document structured like this:
{
type: "like" | "reply" | "mention",
receiver: Profile,
time: number,
subdata: {} // Structure depends on the value of "type"
}
When resolving those documents, I need to use nested if-then-else to resolve subdata:
If(
Equals(Var("type"), "like"),
Call("resolve_like_notif", Var("notif")),
If(
Equals(Var("type"), "reply"),
Call("resolve_reply_notif", Var("notif")),
If(
Equals(Var("type"), "mention"),
Call("resolve_mention_notif", Var("notif")),
null
)
)
)
Is there a cleaner way to do this?