From da207d927db93e2b6565a47224ab9ac37ae3848c Mon Sep 17 00:00:00 2001 From: sadmann7 Date: Sun, 3 Mar 2024 21:59:59 +0600 Subject: [PATCH] chore: unique code --- src/app/_lib/actions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/_lib/actions.ts b/src/app/_lib/actions.ts index 6c639c27..5ea41f39 100644 --- a/src/app/_lib/actions.ts +++ b/src/app/_lib/actions.ts @@ -5,6 +5,7 @@ import { db } from "@/db" import { tasks, type Task } from "@/db/schema" import { faker } from "@faker-js/faker" import { eq } from "drizzle-orm" +import { customAlphabet } from "nanoid" import type { z } from "zod" import { createId } from "@/lib/utils" @@ -27,7 +28,7 @@ export async function seedTasks({ for (let i = 0; i < count; i++) { allTasks.push({ id: createId(), - code: `TASK-${faker.number.int({ min: 1000, max: 9999 })}`, + code: `TASK-${customAlphabet("0123456789", 4)()}`, title: faker.hacker .phrase() .replace(/^./, (letter) => letter.toUpperCase()),