When creating self referencing relationship between models we're seeing failures across all relationship types.
const userSchema = z.object({
id: z.number(),
get children() {
return z.array(userSchema).optional()
},
get parent() {
return userSchema.optional()
},
})
const users = new Collection({ schema: userSchema })
users.defineRelations(({ one, many }) => ({
children: many(users, { role: 'children' }),
parent: one(users, { role: 'children' }),
}))
const child = await users.create({
id: 1,
})
const parent = await users.create({
id: 2,
children: [child],
})
This should result in a child with a parent and a parent with one child. Instead you get a child with itself as children.
When creating self referencing relationship between models we're seeing failures across all relationship types.
Eg:
This should result in a child with a parent and a parent with one child. Instead you get a child with itself as
children.