kstulgys
kstulgys•9mo ago

Can I make table relation field optional? Example 👇

users: defineEnt({})
.field("email", v.string(), { unique: true })
.edges("apiKeys", { ref: true }),
.edges("downloads", { ref: true })

apiKeys: defineEnt({})
.field("hashedApiKey", v.string(), { unique: true })
.edges("downloads", { ref: true })
.edge("user"),

downloads: defineEnt({})
.edge("user")
.edge("apiKey"),
users: defineEnt({})
.field("email", v.string(), { unique: true })
.edges("apiKeys", { ref: true }),
.edges("downloads", { ref: true })

apiKeys: defineEnt({})
.field("hashedApiKey", v.string(), { unique: true })
.edges("downloads", { ref: true })
.edge("user"),

downloads: defineEnt({})
.edge("user")
.edge("apiKey"),
I want todo this and this is not working, convex complains:
downloads: defineEnt({})
.edge("user", { optional: true })
.edge("apiKey", { optional: true }),
downloads: defineEnt({})
.edge("user", { optional: true })
.edge("apiKey", { optional: true }),
1 Reply

Did you find this page helpful?