Here are some code snippets to handle database entries, until an admin dashboard exists.

You have to run these scripts via the prisma db seed command. Here is a link to their docs.

The best way is to simply execute commands from the package.json scripts using VS Code IDE:

Untitled

If you are at the root dir level of the project you can simply run:

pnpm prisma:seed and it will work.

First, edit the /packages/database/prisma/seed.ts file with what you need and the proper information. I’ll suggest editing existing script snippets and keep one commented out for reference next time.

Tags

const newTag = await prisma.tags.create({
    data: {
      tagName: "new_tag_name", // show in UI
      tagDescription: "new_tag_description", // not shown in UI
    },
  });
  console.log({ newTag });

Notice that on the data object you don’t need to put all the fields, you just need to send the fields you want to update

const updatedTag = await prisma.tags.update({
    where: {
      id: "tag_id_to_edit",
    },
    data: {
		  tagName: "new_tag_name", // show in UI
      tagDescription: "new_tag_description", // not shown in UI
    },
  });
  console.log({ updatedTag });

Tracks