From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework

Unlock this course with a free trial

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

Adding product to database, part 1

Adding product to database, part 1

All right, so now we will add the products inside the database. So follow along with me. First I'll open the products entity. And after the price column, I'll give a new column of image. I'll give the image property of type string. And for the column, I'll specify the type to variable character, length to 255 and nullable to false so that the field cannot take the null values. Just like we updated the entity, let's update the product DTO file as well. Here after the price property, I'll define the image property of type string. Now inside the products controller file, I'll remove the getAllRoute as we already have bound the getAll method inside the app controller for the home route. So no need to define it again inside the product controller. Now as we want to add the products, we will be dealing with the post route handler, that is the create route. I'll just update the add product method by removing the return statement message and instead specify the return statement with the…

Contents