Where clause on 'with' in findMany

export const getOrgsByMembershipList = cache(async () => {
  const user = await getAuthUser();

  if (!user) {
    throw new Error("User not found");
  }

  const result = await db.query.membership.findMany({
    where: eq(membership.profileId, user.id),
    with: {
      org: {
        columns: {
          id: true,
          name: true,
        },
        where: eq(org.defaultOrg, false),
      },
    },
  });

  return result;
});
Was this page helpful?