From c8c33c9aa0b51caccda0a8f01f145584e86d6a15 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Thu, 8 Dec 2022 13:16:23 +0100 Subject: [PATCH] fix: wrong base case --- server/routes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes.ts b/server/routes.ts index e9cdc3d..f11e8c3 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -197,7 +197,7 @@ export async function createApiRouter() { return } - const problemNextId = (await getProblems(db)).map(p => parseInt(p.id)).reduce((acc, v) => Math.max(acc, v), 1) + 1 + const problemNextId = (await getProblems(db)).map(p => parseInt(p.id)).reduce((acc, v) => Math.max(acc, v), 0) + 1 const id = await createProblem(db, { title: req.body.title ?? `Problema ${problemNextId}`,