trpc demo
This commit is contained in:
10
src/server/routers/_app.ts
Normal file
10
src/server/routers/_app.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { router } from "../trpc";
|
||||
import { CvCategoryRouter } from "./cvCategory";
|
||||
import { publicProcedure } from "~/server/trpc";
|
||||
|
||||
export const trpcRouter = router({
|
||||
hello: publicProcedure.query(async () => "world"),
|
||||
cvCategory: CvCategoryRouter
|
||||
})
|
||||
|
||||
export type TrpcRouter = typeof trpcRouter
|
||||
12
src/server/routers/cvCategory/index.ts
Normal file
12
src/server/routers/cvCategory/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { db } from "~/server/db";
|
||||
import { publicProcedure, router } from "~/server/trpc";
|
||||
|
||||
export const CvCategoryRouter = router({
|
||||
get: publicProcedure.query(async () => {
|
||||
const categories = await db.query.cvCategory.findMany({
|
||||
orderBy: (model, {desc} ) => desc(model.name)
|
||||
});
|
||||
return categories;
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user