Files
calendar/packages/lib/server/repository/PrismaAttributeToUserRepository.ts
T
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Anik Dhabal Babu
4489cb8fde refactor: rename repository files to include Repository suffix (#22717)
* refactor: rename repository files to include Repository suffix

- Rename attribute.ts -> attributeRepository.ts
- Rename attributeOption.ts -> attributeOptionRepository.ts
- Rename attributeToUser.ts -> attributeToUserRepository.ts
- Update all import statements throughout codebase

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: rename repository files and classes with Prisma prefix

- Rename attribute.ts -> PrismaAttributeRepository.ts
- Rename attributeOption.ts -> PrismaAttributeOptionRepository.ts
- Rename attributeToUser.ts -> PrismaAttributeToUserRepository.ts
- Update class names to PrismaAttributeRepository, PrismaAttributeOptionRepository, PrismaAttributeToUserRepository
- Update all import statements and references throughout codebase

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: update missed AttributeRepository import to PrismaAttributeRepository in teams members page

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-07-30 14:33:25 +02:00

48 lines
1.3 KiB
TypeScript

import type { Prisma } from "@prisma/client";
import prisma from "@calcom/prisma";
export class PrismaAttributeToUserRepository {
static async createManySkipDuplicates(data: Prisma.AttributeToUserCreateManyInput[]) {
return await prisma.attributeToUser.createMany({ data, skipDuplicates: true });
}
static async deleteMany(where: Prisma.AttributeToUserWhereInput) {
if (Object.keys(where).length === 0) {
throw new Error("Empty where clause provided to deleteMany. Potential data loss risk.");
}
return await prisma.attributeToUser.deleteMany({ where });
}
static async findManyIncludeAttribute(where: Prisma.AttributeToUserWhereInput) {
return await prisma.attributeToUser.findMany({
where,
include: {
attributeOption: {
select: {
attribute: true,
value: true,
slug: true,
},
},
},
});
}
static async findManyByOrgMembershipIds({ orgMembershipIds }: { orgMembershipIds: number[] }) {
if (!orgMembershipIds.length) {
return [];
}
const attributesAssignedToTeamMembers = await prisma.attributeToUser.findMany({
where: {
memberId: {
in: orgMembershipIds,
},
},
});
return attributesAssignedToTeamMembers;
}
}