Last active
November 3, 2022 03:10
-
-
Save HectorBlisS/0baf497cd886cd524391584f8206d132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const faker = require('@faker-js/faker').faker // commonjs | |
const PrismaClient = require('@prisma/client').PrismaClient | |
const prisma = new PrismaClient() | |
const getProduct = ()=> { | |
const name = faker.commerce.productName() | |
return ({ | |
slug:faker.helpers.slugify(name), | |
name, | |
body:faker.commerce.productDescription(), | |
images:[ | |
faker.image.imageUrl(), | |
faker.image.imageUrl(), | |
faker.image.imageUrl(), | |
], | |
color: faker.color.human() | |
}) | |
} | |
const saveInDB = async () => prisma.product.create({data:getProduct()}) // <== Cambia este create por .createMany y coloca la lógica necesaria | |
const seed = async()=>{ | |
await Promise.all([...Array(20).keys()].map(saveInDB)) | |
} | |
seed() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment