2
0
Files
cal/calcom/packages/lib/server/getUsersCredentials.ts
2024-08-09 00:39:27 +02:00

20 lines
557 B
TypeScript

import { prisma } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
type SessionUser = NonNullable<TrpcSessionUser>;
type User = { id: SessionUser["id"] };
export async function getUsersCredentials(user: User) {
const credentials = await prisma.credential.findMany({
where: {
userId: user.id,
},
select: credentialForCalendarServiceSelect,
orderBy: {
id: "asc",
},
});
return credentials;
}