This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { router, publicProcedure } from "./trpc";
|
||||
import { db } from "./db";
|
||||
import { user } from "./schema";
|
||||
import { user, userOpinion } from "./schema";
|
||||
import { count, eq } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
|
||||
@@ -29,7 +29,17 @@ export const adminRoute = router({
|
||||
removeUser: publicProcedure
|
||||
.input(z.object({ cid: z.string() }))
|
||||
.mutation(async ({ input }) => {
|
||||
let thisUser = await db.query.user
|
||||
.findFirst({ where: eq(user.cid, input.cid) })
|
||||
.execute();
|
||||
if (thisUser === undefined) {
|
||||
return "User not found";
|
||||
}
|
||||
let uoresult = await db
|
||||
.delete(userOpinion)
|
||||
.where(eq(userOpinion.userId, thisUser.id))
|
||||
.execute();
|
||||
let rs = await db.delete(user).where(eq(user.cid, input.cid)).execute();
|
||||
return rs;
|
||||
return { useropinion: uoresult, rs };
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user