create category dialog
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
} from "@/server/api/trpc";
|
||||
import { categories } from "@/server/db/schema";
|
||||
|
||||
import { eq } from "drizzle-orm";
|
||||
import { count, eq } from "drizzle-orm";
|
||||
import { hasPermission, Role } from "@/lib/validation/permissions";
|
||||
import { categorySchema } from "@/lib/validation/zod/category";
|
||||
import { generateSlug } from "@/lib/utils";
|
||||
@@ -24,6 +24,10 @@ export const categoryRouter = createTRPCRouter({
|
||||
return await ctx.db.query.categories.findMany();
|
||||
}),
|
||||
|
||||
getCount: publicProcedure.query(async ({ ctx }) => {
|
||||
return (await ctx.db.select({ count: count() }).from(categories))[0]?.count;
|
||||
}),
|
||||
|
||||
create: protectedProcedure
|
||||
.input(z.object({ category: categorySchema }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
Reference in New Issue
Block a user