Michael Grigoryan
06/29/2021, 8:36 PMimport faker from "faker";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export async function seed() {
const user = await prisma.user.create({
data: {
lastName: faker.name.lastName(),
firstName: faker.name.firstName(),
},
});
const post = await prisma.post.create({
data: {
userId: user.id,
body: faker.lorem.slug(300),
},
});
console.log({ post, user });
}
The information is not being logged and is not being saved to the database... Is there something wrong or am I doing something not correctly?janpio
Mahmoud
06/30/2021, 4:28 AMseed.js
file inside the /prisma
directory? And youโre using the npx prisma db seed --preview-feature
command right?Michael Grigoryan
06/30/2021, 8:40 AMMichael Grigoryan
06/30/2021, 8:40 AMjanpio
janpio
janpio
Michael Grigoryan
06/30/2021, 10:11 AMMichael Grigoryan
06/30/2021, 1:02 PMMichael Grigoryan
06/30/2021, 1:02 PMMichael Grigoryan
06/30/2021, 1:06 PMseed();
call in the end of my file it workedMahmoud
06/30/2021, 1:08 PMMichael Grigoryan
06/30/2021, 1:08 PMjanpio
Mahmoud
06/30/2021, 1:15 PMseed
should work. I tried it before https://www.prisma.io/docs/guides/database/seed-database#requirements-for-seeding-with-typescript-or-javascriptMahmoud
06/30/2021, 1:16 PMMichael Grigoryan
06/30/2021, 1:17 PMMichael Grigoryan
06/30/2021, 1:21 PM