Oh well, it works. Someone please holler at me if ...
# orm-help
c
Oh well, it works. Someone please holler at me if they have a really slick way to seed a db
you can use a json file, but it's picky about structure and relations can be a bit weird too
c
Interesting… So you just manually create a bunch of records, do an
export
to save their data locally, then reuse that data via
import
to return your db back to whatever state it was at.
j
that's one of the possibilities
c
😁
I’ll look more into it, ty
j
or you can use mockaroo.com to generate 1000 rows of json data, and paste it into the json file
c
You can check my way of doing seed for Location example: https://github.com/catalinmiron/prisma-graphql-coordinates/blob/master/server/src/resolvers/Mutation/location.js#L18. This is going to "fail" because I'm not returning anything from the seed but is populating the DB. I can also make it return something and you're not going to receive an error 🙂
c
Ah I’d rather use
prisma seed --reset
. Jared’s
prisma import
method seems nice.
I’m generating random data on every
prisma seed --reset
now via Faker, but maybe [fairly] static data.json’s will be better. 🤔
c
Hmm... but you can
Seed
Chance/Faker with a number and so it will return the same data again and again 🙂
❤️ 1
🤯 1
For my example worked well.. you might have a different behaviour
c
Holy shit
c
:)) brainfu** prisma seed with a chance seed:))
c
Works perfect as long as creating related models is pretty straightforward
(I suspect it will be)
Thank you so much!