Chapters
00:00 - User Model Relationships
03:15 - Role Model
03:52 - Organization Model
06:22 - AccessLevel, Difficulty, & Status Models
08:18 - Course Model
12:20 - Module Model
13:35 - Lesson Model
14:53 - EmailHistory Model
15:30 - OrganizationInvite Model
18:15 - PasswordResetToken Model
Join The Discussion! (7 Comments)
Please sign in or sign up for free to join in on the dicussion.
aaron-ford
If we want to define single or multi column indexes for our tables, do we do that in the migrations files?
Please sign in or sign up for free to reply
tomgobich
Yeah, you can do that via a migration! There is an
index
anddropIndex
method for that. The KnexJS documentation has more info on the options these accept, which will vary depending on your database driver.Please sign in or sign up for free to reply
inox
One thing I'm curious about is why we don't specify timestamps on the BaseModel. And the same for migrations - we always duplicate table.timestamp. Is it not worth spending time on (extracting common parts)?
Please sign in or sign up for free to reply
inox
Ok, we can use mixins
Please sign in or sign up for free to reply
tomgobich
Sorry for the delayed response!! Yes, if you'd like, you can definitely use mixins to extract those out of your models into a reusable bit of code. That would look very similar to what we do in the next lesson with our organization!
Personally, I never bother to do this with my timestamps because when we use the Ace CLI to create our migrations & models those timestamps come with that stub automatically, so it is actually more work to extract them than it is to just leave them be. Plus, they're consistent enough to be easily updated across the board with a find/replace if needed.
Please sign in or sign up for free to reply
inox
Yeah, now I see, if it takes more time to extract it's ok to have some duplication. Thank you
Please sign in or sign up for free to reply
tomgobich
Exactly! It's all a balancing act. Anytime, inox!! 😊
Please sign in or sign up for free to reply