Convex Ents 1:many rel

Hey! I'm playing around a bit with Convex Ents and I'm running into an issue which I don't know if it's due to my lack of understanding how edges works. I've got two tables with a 1:many relationships, organisers can have many events or none, and events can have one organiser or none. So my idea was this:
events: defineEnt({[...]})
.edge("organiser", { optional: true }),
organisers: defineEnt({[...]})
.edges("events")
events: defineEnt({[...]})
.edge("organiser", { optional: true }),
organisers: defineEnt({[...]})
.edges("events")
Getting no TS warnings in my IDE, but when saved I get this response from the CLI:
[1] Uncaught Error: Unexpected inverse edge type organiser, events
[2] at defineEntSchema (../../../node_modules/convex-ents/src/schema.ts:115:12)
[3] at <anonymous> (../convex/schema.ts:5:20)
[1] Uncaught Error: Unexpected inverse edge type organiser, events
[2] at defineEntSchema (../../../node_modules/convex-ents/src/schema.ts:115:12)
[3] at <anonymous> (../convex/schema.ts:5:20)
Am I doing something wrong or is it simply impossible for the singular edge to be optional? I noticed the docs say that optional 1:1 are not supported but I figured this is a 1:many so it might not apply.
3 Replies
Michal Srb
Michal Srbโ€ข9mo ago
You got it right, optional 1:many edges are not supported yet: https://github.com/xixixao/convex-ents/issues/5
GitHub
1:many edges require single cardinality end to be required ยท Issue ...
This will require more configuration, especially for cascading deletes. We'll hold off on adding this until we get people asking for it.
๐— ๐—œ๐—–๐—ž๐—˜๐—ฌ
All right! Then I guess if I wanna stick to Ents the second best option is to create a many:many relationship? Otherwise it's always possible to do it in vanilla Convex, right? Also thanks for the quick reply! ๐Ÿ™
Michal Srb
Michal Srbโ€ข9mo ago
Yup, especially if you don't need cascading deletes then vanilla approach (which still works with Ents), is best. So v.optional(v.id("otherTable"))

Did you find this page helpful?