Matt LuoM
Convex Communityβ€’2y agoβ€’
29 replies
Matt Luo

Convex Ents: how to express optional reference in 1 to many relationship?

From this documentation https://labs.convex.dev/convex-ents/schema, I'm trying to figure out a common use case, how to express zero-or-many?

Looking at the documentation's example, how can I express that a user can have zero or many messages?
defineEntSchema({
  users: defineEnt({
    name: v.string(),
  }).edges("messages", { ref: true }),
  messages: defineEnt({
    text: v.string(),
  }).edge("user"),
});
Was this page helpful?