27 lines
772 B
TypeScript
27 lines
772 B
TypeScript
import { publicProcedure, router } from "~/server/trpc";
|
|
import { db } from "~/server/db";
|
|
import { z } from 'zod';
|
|
export const cvEntryRouter = router({
|
|
getById: publicProcedure.input(z.string()).query(async ({input}) => {
|
|
const res = await db.query.cvEntry.findFirst({
|
|
with: {
|
|
category: true
|
|
},
|
|
where(fields, operators) {
|
|
return operators.eq(fields.id, input)
|
|
},
|
|
})
|
|
return res;
|
|
}),
|
|
byCategoryAndToDateDescending: publicProcedure.input(z.string()).query(async ({input}) => {
|
|
const res = await db.query.cvEntry.findMany({
|
|
with: {
|
|
category: true
|
|
},
|
|
where: (fields, {eq}) => eq(fields.categoryId,input),
|
|
orderBy: (t,{desc}) => desc(t.toTime),
|
|
})
|
|
return res;
|
|
})
|
|
});
|