hyperzoneH
Convex Communityβ€’2y agoβ€’
9 replies
hyperzone

'remove' in convex-ents patch not working

I'm reposting this from my old thread that didn't get any replies:
Creating many to many ents works (using add inside a patch), but remove doesn't work on both sides:
const category = await ctx
      .table("categories")
      .getX(categoryId); // Id<"categories">

    await category.patch({
      items: {
        remove: items, // Id<"items">[]
      },
    });


the other side also doesn't work which is - getX each item and remove [category_.id] in a patch call

this is the relevant part of the schema:
    categories: defineEnt({
      name: v.any(),
      description: v.any(),
    })
      .field("isEnabled", v.boolean(), { default: true })
      .edge("menu")
      .edges("items"),
    items: defineEnt({
      name: v.any(),
      description: v.any(),
      price: v.float64(),
      isEnabled: v.boolean(),
    })
      // item can be in multiple menus and categories
      .edges("categories")
      .edges("menus")
      .edge("businesse"),

I'm not getting errors or anything, it just executes the mutation but the relevant categories_to_items document doesn't get deleted
Was this page helpful?