much 2 yearn
much 2 yearn
Explore posts from servers
DTDrizzle Team
Created by much 2 yearn on 9/25/2024 in #help
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;
});
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;
});
7 replies