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
And now as the final one
of the four CRUD operations,
we have deleting documents.
And so by now this should already be pretty familiar.
And that's why I want to leave this one to you
as a challenge, all right?
So again, this one is gonna be pretty similar
to update tour only with a small number
of differences, but I think you can figure out
how it works, for example, using the documentation
and of course the other handle functions as an example.
Okay, so keep in mind that here for example
we used find by ID and update
and so you probably can already guess
how this method is gonna be called in delete tour.
All right.
And again, if you're not sure,
you can take a look at the documentation
and what kind of data it expects
and then based on all that, try to implement it.
Okay.
So please pause the video here and take a minute
to really try to do it on your own.
Okay, hope you got that one to work
and anyway, here goes my quick solution.
So again, defining this one as an async function
then try catch.
Here is the error and then let's move this one up.
Get this error response from over here.
And now we are gonna use
tour.findByIdAndDelete
and now all this method here actually needs
is the tour ID.
So req.params.id and I hope you figured
this one out from the documentation.
Then of course we need to await in order
for the deletion actually to happen
and that's actually alt.
So in this case, we actually don't save anything
to any variable because remember,
we actually don't send anything back
to the client, okay.
So in a RESTful API, it is a common practice not
to send back any data to the client
when there was a delete operation, okay.
And also the 204 is kind of a standard as well.
So give us a save now and it should actually already work
like this.
And so to start, let's just create some stupid tour here.
So let's create a Jonas tour here.
Give it a save and so,
when we get all tours, indeed it's gonna be here
and so let's go ahead, copy the ID,
then open or delete tour route here
and then all we need is to really send this delete request
to this route, hit send.
And so again, we get back the 204 status code
and Postman in that case actually doesn't display anything.
All right.
And just to make sure, let's confirm it very quick.
And yeah, it's gone from here.
And so our tour was effectively deleted.
Okay, now if you didn't manage
to complete the challenge on your own,
then of course that's no problem at all.
I just wanted you to think about it
and most of all take a look at the documentation
on your own because it really makes
all the difference for you to start practice
this kind of stuff as soon as possible.
Anyway, with this we implemented
the basic CRUD operations.
The next video we will then finally really start
to model or tour a bit better.
So right now we only have names,
prices, and ratings, and that's not really enough
to describe a tour and so yeah,
in the next video we will kind of create
a better, a bigger, more complete model.
So I hope to see you there soon.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.