refactor packages
This commit is contained in:
30
packages/db/src/services/project.service.ts
Normal file
30
packages/db/src/services/project.service.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { db } from '../prisma-client';
|
||||
|
||||
export type IServiceProject = Awaited<ReturnType<typeof getProjectById>>;
|
||||
|
||||
export function getProjectById(id: string) {
|
||||
return db.project.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function getProjectsByOrganizationSlug(slug: string) {
|
||||
return db.project.findMany({
|
||||
where: {
|
||||
organization_slug: slug,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getProjectWithMostEvents(slug: string) {
|
||||
return db.project.findFirst({
|
||||
where: {
|
||||
organization_slug: slug,
|
||||
},
|
||||
orderBy: {
|
||||
eventsCount: 'desc',
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user