Files
calendar/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredential.ts
T
Shyam RaghuwanshiandGitHub 477e102388 feat: Split-large-code-file-functions (#13592)
* Split large code file functions

* move the files from root into lib
2024-02-16 10:32:00 -03:00

24 lines
638 B
TypeScript

import prisma from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import type { CredentialPayload } from "@calcom/types/Credential";
/**
* Refreshes a Credential with fresh data from the database.
*
* @param credential
*/
export async function refreshCredential(credential: CredentialPayload): Promise<CredentialPayload> {
const newCredential = await prisma.credential.findUnique({
where: {
id: credential.id,
},
select: credentialForCalendarServiceSelect,
});
if (!newCredential) {
return credential;
} else {
return newCredential;
}
}