From the course: Nest.js Developer Lab 2026: Build a Robust API with Authentication, Articles, and User Profiles

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Creating article method

Creating article method

In this video, we will fully create createArticle method, and actually it will be super similar to our method of create that we used for registration of the user. So we need a method inside controller, we need a service method that will do insertion inside our database, and of course we need our DTO to have a payload of creating an article. So here I will jump inside source, article, controller, and here is our create method. But we have here something interesting. Actually if we will check the specification, you can see that for create article authentication is required. So actually this means that we will have here user ID, and without this user ID we can't really create an article. Because article must belong to one user. actually brings us to the topic of relations. Why relations? Because we have now relations between tables. First of all we have the table of the users where we have for example an ID and a name of the user and we have a table with the article. So when we are…

Contents