parent
657076d396
commit
e3b9108835
@ -0,0 +1,47 @@
|
|||||||
|
import { createRouter } from './context';
|
||||||
|
|
||||||
|
import type { Resume } from '~/types/resume';
|
||||||
|
|
||||||
|
export const resumesRouter = createRouter().query('list', {
|
||||||
|
async resolve({ ctx }) {
|
||||||
|
const resumesData = await ctx.prisma.resumesResume.findMany({
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: {
|
||||||
|
comments: true,
|
||||||
|
stars: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resumesProfile: {
|
||||||
|
select: {
|
||||||
|
user: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: 'desc',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return resumesData.map((r) => {
|
||||||
|
const resume: Resume = {
|
||||||
|
additionalInfo: r.additionalInfo,
|
||||||
|
createdAt: r.createdAt,
|
||||||
|
experience: r.experience,
|
||||||
|
id: r.id,
|
||||||
|
location: r.location,
|
||||||
|
numComments: r._count.comments,
|
||||||
|
numStars: r._count.stars,
|
||||||
|
role: r.role,
|
||||||
|
title: r.title,
|
||||||
|
updatedAt: r.updatedAt,
|
||||||
|
url: r.url,
|
||||||
|
user: r.resumesProfile.user.name!,
|
||||||
|
};
|
||||||
|
return resume;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
export type Resume = {
|
||||||
|
additionalInfo: string?;
|
||||||
|
createdAt: Date;
|
||||||
|
experience: string;
|
||||||
|
id: string;
|
||||||
|
location: string;
|
||||||
|
numComments: number;
|
||||||
|
numStars: number;
|
||||||
|
role: string;
|
||||||
|
title: string;
|
||||||
|
updatedAt: Date;
|
||||||
|
url: string;
|
||||||
|
user: string;
|
||||||
|
};
|
Loading…
Reference in new issue