
No Comments Yet
Be the first to share your thoughts and start the conversation.
Be the first to share your thoughts and start the conversation.
Complete source code available till this point of lesson is available at
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
In this lesson, we focus on implementing a new feature called collections that allow users to bookmark or favorite specific questions. This involves creating a new database model to manage these collections effectively.
collection.model.ts
.types.ObjectId
for both the author and question fields.00:00:02 Let's implement the collection model.
00:00:04 Remember how we had tags not that long ago?
00:00:07 Well, now we're going to implement collections.
00:00:10 Collections allow you to store or bookmark or favorite specific questions.
00:00:16 You see this star?
00:00:17 That's it.
00:00:18 It allows you to start it and add it to your collection.
00:00:21 So let's implement it by creating a new database model called collection.model.ts.
00:00:28 Let's copy the template model into the collection model.
00:00:32 And let's simply change this name from model to collection.
00:00:38 Great.
00:00:39 Now let's define it.
00:00:41 It'll be super straightforward.
00:00:42 The only thing we need to keep track of is the author, meaning who is adding it to the collection.
00:00:49 That's going to be a schema.types, come on Copilot, learn it already, with a reference to a user and required to set the true.
00:00:58 And the question as well, which is going to be a reference to a question.
00:01:04 Great.
00:01:05 Good boy, GitHub Copilot.
00:01:06 Finally, let's define the type.
00:01:09 Author will be set to types.ObjectId and question will be types.ObjectId as well.
00:01:16 Great.