WEBVTT

00:03.820 --> 00:05.260
Hey there, everyone here.

00:05.290 --> 00:06.610
And welcome to another video.

00:06.610 --> 00:09.310
In this video, we're going to design a product model.

00:09.340 --> 00:11.770
Now, the product model can be called with variety of names.

00:11.770 --> 00:16.630
You can call it as t shirt model, you can call it as a course model in case you are designing an education,

00:16.630 --> 00:17.800
LMS or something.

00:17.800 --> 00:23.170
You can also call your A product as simply the order or the food item somebody is placing or a pizza,

00:23.170 --> 00:24.310
whatever you like to call it.

00:24.310 --> 00:28.750
There can be many names and there is ridiculous amount of similarities in the product itself.

00:28.780 --> 00:33.070
Now another important thing is each of these products are also going to have a reviews.

00:33.220 --> 00:38.860
Now, if this would be something like my school or something, I would love to create a different table

00:39.430 --> 00:41.250
itself for the reviews itself.

00:41.260 --> 00:46.420
But since we are talking about the NoSQL database, one of the advantages we can just inject all things

00:46.420 --> 00:51.130
up here, and even though it is a little bit sounds complex, but it is not, this is how exactly the

00:51.130 --> 00:52.840
NoSQL is being designed for.

00:52.930 --> 00:57.900
So let's go ahead and create another model and we are going to call this one as simply product.

00:57.910 --> 01:01.150
Now, this product, again, as I told you, it can be anything at all.

01:01.930 --> 01:05.130
So what we're going to do again, same kind of a sticky note.

01:05.140 --> 01:07.390
Let's go ahead and pick up with a different color.

01:07.390 --> 01:08.440
Let's go with a green.

01:09.070 --> 01:09.460
Yep.

01:09.460 --> 01:10.570
That sounds good.

01:11.520 --> 01:11.790
Okay.

01:11.790 --> 01:14.010
So let me bring it up here a little bit.

01:14.040 --> 01:14.790
Looks great.

01:14.820 --> 01:15.360
Now what?

01:15.360 --> 01:16.950
We're going to go ahead and call this one.

01:16.950 --> 01:20.100
So, again, a product is always going to have a name and a price.

01:20.100 --> 01:22.500
This is pretty obvious and a description as well.

01:22.680 --> 01:24.090
So description.

01:24.090 --> 01:25.440
So these are common things.

01:25.450 --> 01:28.770
We all know that the product is going to have a name, price and description.

01:28.770 --> 01:30.690
What all what else is going to have?

01:30.720 --> 01:32.700
It's going to have an image as well.

01:32.820 --> 01:35.520
Let's just call it as photo, keep the things as same.

01:35.520 --> 01:38.250
So this is going to be photo, but this is not going to be photo.

01:38.280 --> 01:42.840
This is going to be photos because a product can have multiple photos in this case.

01:42.840 --> 01:44.550
So we're going to be keeping it as an array.

01:44.550 --> 01:46.200
What we're going to inject in this setting.

01:46.230 --> 01:47.460
Yes, you guessed it right.

01:47.460 --> 01:54.060
Just like previously, we are going to inject an an object which will contain an ID and a security model.

01:54.060 --> 01:56.580
So we'll be injecting as many as we like into this array.

01:56.580 --> 01:57.330
So pretty simple.

01:57.330 --> 01:58.380
No big deal there.

01:59.220 --> 02:01.470
It will also have a category.

02:01.590 --> 02:06.480
Now, since we don't have too much of the things to be worried about, the categories there are only

02:06.480 --> 02:07.020
just for.

02:07.050 --> 02:11.010
That's why we are going to be calling an E nums, which will help us to explore the enum a little bit

02:11.010 --> 02:11.820
better as well.

02:11.820 --> 02:16.200
But don't worry, we will learn how to inject different model into other models as well.

02:16.200 --> 02:21.090
So in case for the future, you want to have a separate model for the categories itself.

02:21.090 --> 02:22.410
It's ridiculously simple.

02:22.410 --> 02:24.240
So you can actually you will be able to do it.

02:24.240 --> 02:25.350
Don't you worry on that.

02:25.560 --> 02:25.870
Okay.

02:25.920 --> 02:29.550
Once we are done with the categories and all of that, we will also inject a brand.

02:29.550 --> 02:30.510
Now why brand?

02:30.510 --> 02:33.780
Right now we are selling all the t shirts with the name of AE.

02:33.780 --> 02:39.120
Maybe later on we want to sell t shirts from Adidas or Nike or something else, so we'll be keeping

02:39.120 --> 02:39.660
it up here.

02:39.660 --> 02:40.920
It will be a simple string.

02:40.920 --> 02:45.600
You want to have it, keep it if you don't want to have it, no big issue, we can actually move that.

02:45.600 --> 02:49.110
So this is how usually the brand and integrity of the product is designed.

02:49.110 --> 02:53.370
You just brainstorm which which feels you want to have, which feels you don't want to have, and that's

02:53.370 --> 02:54.690
how things are being designed.

02:54.900 --> 02:59.250
Okay, so once we have this one, obviously the one of the requirement was to have a stock.

02:59.250 --> 03:03.930
Now stock is going to be a simple number and we are going to manage this number on our own.

03:03.930 --> 03:09.150
We will design the controllers in such a way that whenever a order is being placed, we'll find out

03:09.150 --> 03:14.010
how many quantities of that product is being ordered and we'll subtract it from the stock itself.

03:14.010 --> 03:17.820
So this is going to be managed by our self and it will be automatically managed.

03:17.820 --> 03:19.620
The user will not be worried on that.

03:19.740 --> 03:23.280
Now every single of the product is going to have a ratings as well.

03:23.310 --> 03:29.640
Now this ratings field is going to be taking care of what is the average rating of the product.

03:29.640 --> 03:31.230
So we need to calculate that as well.

03:31.260 --> 03:38.370
As soon as somebody adds a review, we'll take his rating and we'll kind of adjust in this rating field

03:38.370 --> 03:38.640
here.

03:38.640 --> 03:43.050
So this is going to be interesting to work on that, how we figured out the ratings part as well.

03:43.620 --> 03:49.020
Now, it will be helpful for us if we go ahead and say a number of reviews now why we want to have a

03:49.020 --> 03:50.130
number of reviews.

03:50.460 --> 03:54.540
There will be obviously a field in the website itself which says total number of reviews.

03:54.540 --> 04:00.480
But not only that, it will also help us to design decide the ratings, which we just wrote above,

04:00.480 --> 04:06.360
how the number, the total rating is going to be, that whatever the ratings are divided by the number

04:06.360 --> 04:07.080
of reviews we have.

04:07.080 --> 04:10.440
So calculating the average, this field is going to help us at that point also.

04:10.440 --> 04:14.880
So a number of reviews, again, it's not going to be too much important, but I think this is an important

04:14.880 --> 04:15.390
part.

04:15.570 --> 04:17.970
Further down the road, we will have the reviews.

04:17.970 --> 04:21.090
Now, what this reviews is going to be, this is going to be in array again.

04:21.240 --> 04:23.760
Now, what we're going to fill up into this reviews.

04:23.760 --> 04:27.540
So what I will do, I will add a user itself.

04:27.540 --> 04:32.100
So obviously the user model that we have created, we need to inject that so that we can find out who

04:32.100 --> 04:33.810
is the user who has added the rating.

04:34.260 --> 04:36.030
We will take his name also.

04:36.060 --> 04:38.130
We can add his email, but I don't think so.

04:38.130 --> 04:39.840
That's too much necessary.

04:40.020 --> 04:44.640
And we are going to go ahead and collect rating from him and we are going to collect comment on him.

04:44.640 --> 04:51.060
You can call this rating as star as well, but I think rating is itself kind of a decent name for that.

04:51.060 --> 04:52.770
So that's that's okay.

04:52.920 --> 04:54.870
Let me expand this a little bit.

04:57.210 --> 04:58.610
So so far so good.

04:58.660 --> 05:01.770
Now we have a number of we have the ratings average one.

05:01.770 --> 05:05.100
We have number of ratings, total number of reviews given to this product.

05:05.100 --> 05:10.770
We have reviews, which is an array in which user needs to add, enter its rating and comment and we

05:10.770 --> 05:14.430
will automatically collect who is the user who is entering the rating.

05:14.430 --> 05:18.030
So we need to take care about user should be logged in and the name of the user.

05:18.030 --> 05:18.960
So no big deal.

05:19.140 --> 05:20.320
Just kind of a basic.

05:20.340 --> 05:23.850
Now another thing that we are going to inject here is the user itself.

05:23.850 --> 05:30.510
So whoever is the user who is adding this product, we need to take care of that because right now you

05:30.510 --> 05:35.160
are just having one admin, but maybe you want to give this feature to some kind of manager as well

05:35.160 --> 05:35.970
in the future.

05:35.970 --> 05:41.010
So to make it this a little bit future proof, we are going to add this user into the database itself

05:41.010 --> 05:45.750
that, hey, this is this was the guy who actually added this product on to your website.

05:45.750 --> 05:47.160
So pretty okay, pretty good.

05:47.160 --> 05:51.300
And of course, every single of them is going to have a field which is going to be created out.

05:51.300 --> 05:52.650
So no big deal there.

05:53.490 --> 05:55.830
Is this the only thing that we are going to worry about?

05:56.190 --> 05:59.370
No, probably we can add a few more fields can work out with that.

05:59.370 --> 06:03.180
But this is kind of a brainstorming session that I'm having just with you.

06:03.270 --> 06:05.880
So we're going to be keeping this as simple as short.

06:05.970 --> 06:10.650
In case you come up with any more field, you can go ahead and definitely add them once you are done

06:10.650 --> 06:11.130
with the course.

06:11.130 --> 06:13.380
So this is all the basics of product.

06:13.410 --> 06:17.880
Now, again, this kind of discussion actually evolves a little bit more when you are selling the courses

06:17.880 --> 06:22.650
or maybe you are selling some restaurants or the pizza because their fields are going to be different

06:22.650 --> 06:24.540
from what I have used up here.

06:24.540 --> 06:29.730
And in fact, even in the t shirt store, there can be more fields or something more that we can have,

06:29.730 --> 06:31.080
but we're going to keep it short.

06:31.080 --> 06:32.220
Let's keep it up here.

06:32.220 --> 06:37.470
And in the next video, let's talk about how the order model is going to work on when somebody plays

06:37.470 --> 06:40.200
order to our website, how that field is going to look like.

06:40.200 --> 06:41.670
Let's catch up for the next video.
