kstulgysK
Convex Community2y ago
2 replies
kstulgys

Am I doing this ent query correctly?

export const get = authQuery({
  args: {
    orderId: v.id("orders"),
  },
  handler: async (ctx, args) => {
    if (!ctx.user?.currentAccountId) return null;
    const order = await ctx
      .table("accounts")
      .getX(ctx.user.currentAccountId)
      .edgeX("orders")
      .filter((q) => q.eq(q.field("_id"), args.orderId))
      .firstX();
    return order;
  },
});


I want to get order by id but that order must belong to the account that is ctx.user.currentAccountId
Was this page helpful?