Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So before moving on to implementing
some more API features, let's now very quickly import
the rest of our development data.
So data on users, and on reviews.
So, in our dev data folder,
we already imported all the tours, right?
But, we also have a users, and we also have reviews, okay?
So, I have created a bunch of users for us to work with
throughout the rest of the course,
so all of these, I think it's about 20 users,
and then also a bunch of reviews, okay.
And so, all we need to do now is to basically update
or import dev data script, so basically duplicate this here.
So, tours will become users,
and here tours will become reviews.
Then, we also need to import the other two models,
so review, and here as well.
Now all right, and now then here,
also, basically duplicate this, user,
and review.
All right.
And that should probably do with the job, all right.
So, let's go to our other terminal window here, clear this,
and actually the last operation that we did was this one.
So, we need to start by deleting everything we have.
Oh, and I see now that we actually only deleted the tours.
All right, and so we also want to get rid
of all the current users that we have right now
because they are really all just test users, all right.
And the same of course goes for reviews.
So, a gift is a save,
and now deleting all of them,
just taking a quick look into Compass,
and so you see that, indeed, all the users are gone,
and so the same should be true for the other collections.
All right, and so now let's go ahead
and import all of the data.
That's gonna take a little bit of time,
and now, we get this validation error here.
Okay, so please confirm your password.
And so, that's basically because we're creating a new user
without specifying the password confirm property.
So, the solution to that is to actually explicitly turn off
the validation in this case, okay?
And, I'm not sure if we have done that before,
but it's actually very easy.
Okay, so all we need to do is to pass in
an additional object with some options,
and actually in this case, just one.
And, the option that we want is validateBeforeSave,
and set it to false.
Okay, and so with this, all of the validation that we do
in the model will basically just be skipped, okay?
Also, another thing that we need to do
in the model is to turn off the password encryption
because the users that we provide already have
an encrypted password here, all right.
And so, here in our user model,
we now basically just need to comment out
all of these (mumbles).
Okay, and so now,
the password encryption step is also gonna be skipped.
So, we'll give this a save,
and now lets, actually, first of all, delete the data again,
just so we don't create any duplicates,
and now let's try it again with import, and yeah.
This time we didn't get any error,
and so let's take a look at that in Compass,
so we have all the users,
we should have all natours as well.
And, indeed, here they are, and also a couple of reviews.
And, you'll see 60 reviews actually I created, okay?
And let's just confirm
that the passwords for users were not encrypted,
so I'm just copying this one here, just this entire line.
Oh, that doesn't work.
So, let's just copy this string here
and then compare with the one we have in our adjacent file.
So, just the first one here,
and yeah, indeed, you see that it looks
exactly the same as this one, right?
And so, just as we wanted,
the passwords were not encrypted this time.
Okay, so let's close all of this,
make sure to remove the comments that we now put here,
so that in the future of course,
new users will then get their passwords encrypted properly.
So, save this, and now I want to quickly take a look
at the data here.
So, in Postman, and the first thing
that I want to do is to actually log in as an administrator.
All right, so let's take a look at the email address,
and so you see it's actually admin@natours.io, okay?
And, of course the password, we cannot retrieve from here,
but I know, of course, what password I specified,
and so we can use that.
And so, the password
for all of the users here is always test1234, okay?
So, that worked.
So, again for all of the 20 users that I created,
the password is always the same, always test1234.
Great, now let's quickly get all tours here as well.
And so, let's actually just remove this filter here.
Okay, and so we get all our natours,
and now you see that all of them now will have guides.
Okay, so this is a lead guide and a normal guide,
and also all of them will have a bunch of reviews.
Somewhere, so that should be here,
but I believe we only populated the reviews
when we get just one tour,
so that's try that here with the (mumbles).
So, I copied the ID so that I can now put it in here.
Let's send that,
so the guides' locations,
and indeed, now we get all of the reviews.
And of course, just like we configured before
here then the user also gets populated,
and the tour does not.
So, everything still works the same,
but now we have a bunch of more real world data
that we can now start working with
throughout the rest of the course.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.