20 lines
557 B
TypeScript
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;
|
|
}
|