Generating Random User Data with Faker.js for Database Seeding
00:00 Let's jump into our seed script and we'll bring in Faker, just like Marty the money bag wants us to. And then we can use that to help us create a user that has like random information. So we'll await Prisma user create, and here we're gonna have our data. And then our data is gonna include a couple of things.
00:19 We're not gonna provide like necessarily the ID and stuff like that for this user, because this one's gonna be totally random anyway. So we've got our user email, our username and our name. And then for our notes, we want to have this user should have at least one note.
00:37 So let's create a note and that is going to have a title and content. And that should be enough for us. So let's go ahead and run npx Prisma db seed. And with that, we should be able to refresh. And now we've got two notes in here.
00:57 We also have the user, it was stuck in there. And then the user image shouldn't, there should not be a user image. We're not doing anything with that. We're also not doing anything with the note image either. So this new note will not have any images, but it does get us pretty well there.
01:15 And if we want to, we could actually add another note. Why not? And so now if we run the seed script, we should end up with three notes, one for Cody and then the other two that were automatically generated. It's really nice to generate data based on
01:30 something that looks reasonable and matches our schema. And also we didn't have to think about. So that is generating data, simple use of Faker.js.