Open iLucasPires opened 1 day ago
Hi, I'm trying to use the hashPassword function from the nuxt-auth-utils package to hash passwords in a Prisma seed file. However, I'm unable to import or use the function correctly within my seeding logic.
hashPassword
nuxt-auth-utils
import { PrismaClient } from '@prisma/client'; import { hashPassword } from 'nuxt-auth-utils'; // Fails here const prisma = new PrismaClient(); async function main() { const hashedPassword = await hashPassword('user_password'); await prisma.user.create({ data: { email: 'user@example.com', password: hashedPassword, }, }); } main() .catch(e => console.error(e)) .finally(async () => { await prisma.$disconnect(); });
I would appreciate any help or guidance on resolving this issue.
Thanks!
Hi @iLucasPires
I recommend you to use server tasks for seed, see https://nitro.unjs.io/guide/tasks
See example with Drizzle ORM: https://hub.nuxt.com/docs/recipes/drizzle#seed-the-database-optional
Hi, I'm trying to use the
hashPassword
function from thenuxt-auth-utils
package to hash passwords in a Prisma seed file. However, I'm unable to import or use the function correctly within my seeding logic.Example Code (Prisma seed file):
I would appreciate any help or guidance on resolving this issue.
Thanks!