Current section: Generating Seed Data 5 exercises

Dynamically Generating Data


00:00 All right, Kelly did a lot of work for us and I just want to review some of that for you before we add the ability to have dynamic amount of data. So, we want more than just a couple of notes and couple of users. We want to have as many as we want to make it really easy. So, Kelly organized

00:17 things for us a little bit. First of all, she made this create user utility that handles creating this user and even makes the username resemble the name of the user that we created. So, first and last name can kind of matches and email as well. So, that's kind of cool. And then we also

00:36 have this image function that simplifies creating images as well. So, it handles the alt text and the content type as well as reading the file from the file system. So, that ends up being a lot more terse than it was before, which is nice. Thank you, Kelly, the coworker. And then we have the

00:55 seed script. So, now we've got some timings going on in here, which is nice. So, we can see how long it's taking to do each step. We have some emoji to, you know, because emojis are fun. And then we have this total users that now we're going to be creating this many users. And then we have these

01:10 note images already created for us. So, we can use those to like randomly add a certain number of images to our different notes. And then we have user images. So, these would be profile images that are appropriate for a user avatar. And then we have a total users variable

01:29 that we're going to be wrapping up all this user create in so that we can create that many users. You're going to be doing a couple of things to create a random number of notes, a random number of images for those notes, all of that stuff. And like selecting a random user image, all of that.

01:46 And then we also have creating the user Cody and we have Cody's images here as well. So, Cody has some special images for his notes. And we've got our create of Cody. We want to,

02:01 I want you to add Cody's profile image there. And then we're going to swap the hard-coded images with those from this promise hash right here. So, and that is everything that you're going to need to do. And that's what Kelly did for us. Thank you, Kelly. And thank you for working on this. We'll see you when you're done.