fix mongodb templates and add migrate and generate scripts

This commit is contained in:
Aman Varshney
2025-05-02 22:17:51 +05:30
parent 437cf9a45a
commit 0cb24b1494
13 changed files with 765 additions and 443 deletions

View File

@@ -23,7 +23,11 @@ export const todoRouter = {
}),
toggle: publicProcedure
{{#if (eq database "mongodb")}}
.input(z.object({ id: z.string(), completed: z.boolean() }))
{{else}}
.input(z.object({ id: z.number(), completed: z.boolean() }))
{{/if}}
.handler(async ({ input }) => {
await prisma.todo.update({
where: { id: input.id },
@@ -33,7 +37,11 @@ export const todoRouter = {
}),
delete: publicProcedure
{{#if (eq database "mongodb")}}
.input(z.object({ id: z.string() }))
{{else}}
.input(z.object({ id: z.number() }))
{{/if}}
.handler(async ({ input }) => {
await prisma.todo.delete({
where: { id: input.id },
@@ -69,7 +77,11 @@ export const todoRouter = router({
}),
toggle: publicProcedure
{{#if (eq database "mongodb")}}
.input(z.object({ id: z.string(), completed: z.boolean() }))
{{else}}
.input(z.object({ id: z.number(), completed: z.boolean() }))
{{/if}}
.mutation(async ({ input }) => {
try {
return await prisma.todo.update({
@@ -85,7 +97,11 @@ export const todoRouter = router({
}),
delete: publicProcedure
{{#if (eq database "mongodb")}}
.input(z.object({ id: z.string() }))
{{else}}
.input(z.object({ id: z.number() }))
{{/if}}
.mutation(async ({ input }) => {
try {
return await prisma.todo.delete({