update all deps
This commit is contained in:
34
src/server/routers/cvCategory.ts
Normal file
34
src/server/routers/cvCategory.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { publicProcedure, router } from "~/server/trpc";
|
||||
import { db } from "~/server/db";
|
||||
import { cvCategory } from "~/server/dbschema/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { z } from 'zod';
|
||||
import { createInsertSchema, createUpdateSchema } from "drizzle-zod";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
export const cvCategoryRouter = router({
|
||||
listByLayoutPosition: publicProcedure.input(z.enum(cvCategory.layoutPosition.enumValues)).query(async ({input}) => {
|
||||
console.log(input);
|
||||
const res = await db.select().from(cvCategory).where(eq(cvCategory.layoutPosition,input));
|
||||
console.log(res);
|
||||
return res;
|
||||
}),
|
||||
getById: publicProcedure.input(z.string()).query(async ({input}) => {
|
||||
const res = await db.query.cvCategory.findFirst({
|
||||
with: {
|
||||
cvEntry: true
|
||||
},
|
||||
where(fields, operators) {
|
||||
return operators.eq(fields.id, input)
|
||||
},
|
||||
})
|
||||
return res;
|
||||
}),
|
||||
insert: publicProcedure.input(createInsertSchema(cvCategory)).mutation(async ({input}) => {
|
||||
let res = await db.insert(cvCategory).values(input).returning().execute();
|
||||
return res.at(0)
|
||||
}),
|
||||
updateById: publicProcedure.input(z.object({id: z.string(),data: createUpdateSchema(cvCategory)})).mutation(async ({input}) => {
|
||||
let res = await db.update(cvCategory).set(input.data).where(eq(cvCategory.id,input.id)).execute();
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user