Convex Ents, many to many pivot table with additional fields
Cannot find it in the documentation. Is it possible to add custom fields to a many-to-many relationships pivot table with convex Ents and the edges method? Like a collection could belong to many regions and a region can have many collections. If the case you would want to add an archive feature to archive a specific collection for a given region, the pivot table would have a "archivedAt" field to record this, on top of the collectionId and regionId fields. If you see what I mean.
Otherwise, I guess the only is to make it manually with the vanilla convex syntax which would be the same for query and mutation?
1 Reply
Hey @sbkl , not directly no, but you can define the "edge table" as an ent and have 1:many edges from it to the other 2 tables.
I use this approach in the saas-starter:
https://github.com/xixixao/saas-starter/blob/main/convex/schema.ts#L31-L37
Tracking issue: https://github.com/xixixao/convex-ents/issues/12
GitHub
Support many:many edges with data · Issue #12 · xixixao/convex-ents
Right now many:many edges that need to store data (or additional edges) can be modeled by two 1:many edges pointing at the same table. This is good, but perhaps it has some functionality gaps. many...
GitHub
saas-starter/convex/schema.ts at main · xixixao/saas-starter
Convex, Clerk, Next.js, Convex Ents. Contribute to xixixao/saas-starter development by creating an account on GitHub.